aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-04-09 00:17:13 +0930
committerMatthew Draper <matthew@trebex.net>2014-04-09 00:17:13 +0930
commit615e0dcdf1391a8b71ad6556c2e7b9cedf6ffa12 (patch)
treecb9b650c67b99eac5b15a96c6840e07514f51ff1 /activerecord/lib/active_record
parent8f23c220081d0197107490df9aa6e262fac5099e (diff)
downloadrails-615e0dcdf1391a8b71ad6556c2e7b9cedf6ffa12.tar.gz
rails-615e0dcdf1391a8b71ad6556c2e7b9cedf6ffa12.tar.bz2
rails-615e0dcdf1391a8b71ad6556c2e7b9cedf6ffa12.zip
Less ambition, more deprecation
The "DATABASE_URL_*" idea was moving in the wrong direction. Instead, let's deprecate the situation where we end up using ENV['DATABASE_URL'] at all: the Right Way is to explicitly include it in database.yml with ERB.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_handling.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb
index f83829bb26..3667a42864 100644
--- a/activerecord/lib/active_record/connection_handling.rb
+++ b/activerecord/lib/active_record/connection_handling.rb
@@ -72,24 +72,24 @@ module ActiveRecord
private
def config
@raw_config.dup.tap do |cfg|
- urls_in_environment.each do |key, url|
- cfg[key] ||= {}
- cfg[key]["url"] ||= url
- end
- end
- end
-
- def urls_in_environment
- {}.tap do |mapping|
- ENV.each do |k, v|
- if k =~ /\ADATABASE_URL_(.*)/
- mapping[$1.downcase] = v
+ if url = ENV['DATABASE_URL']
+ if cfg[@env]
+ if cfg[@env]["url"]
+ # Nothing to do
+ else
+ ActiveSupport::Deprecation.warn "Overriding database configuration with DATABASE_URL without using an ERB tag in database.yml is deprecated. Please update the entry for #{@env.inspect}:\n\n" \
+ " #{@env}:\n url: <%= ENV['DATABASE_URL'] %>\n\n"\
+ "This will be required in Rails 4.2"
+ cfg[@env]["url"] = url
+ end
+ else
+ cfg[@env] = {}
+ ActiveSupport::Deprecation.warn "Supplying DATABASE_URL without a matching entry in database.yml is deprecated. Please add an entry for #{@env.inspect}:\n\n" \
+ " #{@env}:\n url: <%= ENV['DATABASE_URL'] %>\n\n"\
+ "This will be required in Rails 4.2"
+ cfg[@env]["url"] ||= url
end
end
-
- # Check for this last, because it is prioritised over the
- # longer "DATABASE_URL_#{@env}" spelling
- mapping[@env] = ENV['DATABASE_URL'] if ENV['DATABASE_URL']
end
end
end