Permalink
Browse files

Make sure that RAILS_ENV is set when accessing Rails.env

Fixes #8025
  • Loading branch information...
1 parent d349490 commit b3125c89f42968bec6ee0b92ab93e36dbc36d5c3 @steveklabnik committed Oct 24, 2012
Showing with 6 additions and 1 deletion.
  1. +2 −0 railties/CHANGELOG.md
  2. +4 −1 railties/lib/rails.rb
View
2 railties/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Ensure that RAILS_ENV is set when accessing Rails.env *Steve Klabnik*
+
* Don't eager-load app/assets and app/views *Elia Schito*
* Add `.rake` to list of file extensions included by `rake notes` and `rake notes:custom`. *Brent J. Nordquist*
View
5 railties/lib/rails.rb
@@ -85,7 +85,10 @@ def root
end
def env
- @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
+ @_env ||= begin
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
+ ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"])
+ end
end
def env=(environment)

0 comments on commit b3125c8

Please sign in to comment.