aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_handling.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-07 19:17:43 -0300
committerMatthew Draper <matthew@trebex.net>2014-04-08 15:15:03 +0930
commitd035ba143a46e64e6110b6a690e0655e8574fd49 (patch)
treea3f223c091a5235faf903ae789bc379c7ae83440 /activerecord/lib/active_record/connection_handling.rb
parent2b6d1da6b4f2a5dc1d51223ddb33b86ceab98479 (diff)
downloadrails-d035ba143a46e64e6110b6a690e0655e8574fd49.tar.gz
rails-d035ba143a46e64e6110b6a690e0655e8574fd49.tar.bz2
rails-d035ba143a46e64e6110b6a690e0655e8574fd49.zip
Check env_url only once
Diffstat (limited to 'activerecord/lib/active_record/connection_handling.rb')
-rw-r--r--activerecord/lib/active_record/connection_handling.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb
index a1fb83fde5..08849b3722 100644
--- a/activerecord/lib/active_record/connection_handling.rb
+++ b/activerecord/lib/active_record/connection_handling.rb
@@ -79,9 +79,14 @@ module ActiveRecord
if key.to_s == env
env_url = ENV["DATABASE_URL"]
end
+
env_url ||= ENV["DATABASE_URL_#{key.upcase}"]
- entry ||= {} if env_url
- entry.merge!("url" => env_url) { |h, v1, v2| v1 || v2 } if entry.is_a?(Hash) && env_url
+
+ if env_url
+ entry ||= {}
+ entry.merge!("url" => env_url) { |h, v1, v2| v1 || v2 } if entry.is_a?(Hash)
+ end
+
hash[key] = entry if entry
end