aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/CHANGELOG.md2
-rw-r--r--railties/lib/rails.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index e75ccffe0a..cc77d08684 100644
--- a/railties/CHANGELOG.md
+++ b/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*
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb
index dd51a6fb01..6bf2d8db20 100644
--- a/railties/lib/rails.rb
+++ b/railties/lib/rails.rb
@@ -85,7 +85,10 @@ module Rails
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)