Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 351
user Avatar asked Oct 14 '22 21:10

user


1 Answers

In the documentation:

def env
   @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end
like image 69
marcgg Avatar answered Oct 18 '22 01:10

marcgg