简体   繁体   中英

RAILS_ENV vs Rails.env? And Why the values are different?

I have already read this question : Rails.env vs RAILS_ENV

I have added rails-dev-boost plugin ( http://github.com/thedarkone/rails-dev-boost ) and it internally uses Rails.env.development? to check and bypass its scripts if its not development. This is generally okay.

But I also use Spork Testunit ( http://github.com/timcharper/spork-testunit/ )to fire up a test server to quickly run tests. But this causes problem and loads up rails-dev-boost while running the tests. I checked within the rails-dev-boost plugin's init.rb and it says :

Rails.env.development? # = true
RAILS_ENV # = "test"

Why are these values different? Is there any other things that are settings these values different? Any ideas?

In the documentation :

def env
   @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM