Skip to content

Commit 1e89e43

Browse files
Merge pull request rails#8026 from steveklabnik/issue_8025
Make sure that RAILS_ENV is set when accessing Rails.env
2 parents d349490 + b3125c8 commit 1e89e43

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

railties/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Rails 4.0.0 (unreleased) ##
22

3+
* Ensure that RAILS_ENV is set when accessing Rails.env *Steve Klabnik*
4+
35
* Don't eager-load app/assets and app/views *Elia Schito*
46

57
* Add `.rake` to list of file extensions included by `rake notes` and `rake notes:custom`. *Brent J. Nordquist*

railties/lib/rails.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def root
8585
end
8686

8787
def env
88-
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
88+
@_env ||= begin
89+
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
90+
ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"])
91+
end
8992
end
9093

9194
def env=(environment)

0 commit comments

Comments
 (0)