RAILS_ENV vs Rails.env? And why are the meanings different?

I already read this question: Rails.env vs RAILS_ENV

I added the rails-dev-boost plugin ( http://github.com/thedarkone/rails-dev-boost ) and does it use Rails.env.development internally? check and bypass your scripts, if this is not development. This is usually normal.

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

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

Why are these values ​​different? Are there other things that are settings, are these values ​​different? Any ideas?

+3
source share
1 answer

In the documentation :

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

Source: https://habr.com/ru/post/1771867/


All Articles