aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorKeith Gable <ziggy@ignition-project.com>2014-10-17 16:12:44 -0700
committerKeith Gable <ziggy@ignition-project.com>2014-10-21 11:09:34 -0700
commit5024f6180afb19085d77e0378e1375a42a91d2b5 (patch)
tree24fbbafbfb45218fbc8657d18f7bb1fb8cc85ffd /activerecord/lib/active_record
parent40e904df37253301c23f8abf87135d751bddfa9c (diff)
downloadrails-5024f6180afb19085d77e0378e1375a42a91d2b5.tar.gz
rails-5024f6180afb19085d77e0378e1375a42a91d2b5.tar.bz2
rails-5024f6180afb19085d77e0378e1375a42a91d2b5.zip
If Rails is not defined, check ENV["RAILS_ENV"] and ENV["RACK_ENV"].
This fixes a regression introduced by 6cc03675d30b58e28f585720dad14e947a57ff5b. ActiveRecord, if used without Rails, always checks the "default_env" environment. This would be OK, except that Sinatra also supports environments, and it runs with {RACK|RAILS}_ENV=production. This patch adds a fallback to RAILS_ENV and RACK_ENV (and ultimately default_env) if Rails.env doesn't exist.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_handling.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb
index 31e7390bf7..8f51590c99 100644
--- a/activerecord/lib/active_record/connection_handling.rb
+++ b/activerecord/lib/active_record/connection_handling.rb
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionHandling
- RAILS_ENV = -> { Rails.env if defined?(Rails) }
+ RAILS_ENV = -> { (Rails.env if defined?(Rails)) || ENV["RAILS_ENV"] || ENV["RACK_ENV"] }
DEFAULT_ENV = -> { RAILS_ENV.call || "default_env" }
# Establishes the connection to the database. Accepts a hash as input where