diff options
author | Matthew Draper <matthew@trebex.net> | 2017-02-22 01:59:26 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2017-02-22 05:11:45 +1030 |
commit | 0a4f60090ba6a61a2610d8a0c163cc97e8c95833 (patch) | |
tree | 8e5f8332bfb0268632078b1fe9f636e4b48ca2aa /activerecord/lib/active_record/connection_adapters/connection_specification.rb | |
parent | 5716c4ddf4e03c75bd50df901a515ac445167a99 (diff) | |
download | rails-0a4f60090ba6a61a2610d8a0c163cc97e8c95833.tar.gz rails-0a4f60090ba6a61a2610d8a0c163cc97e8c95833.tar.bz2 rails-0a4f60090ba6a61a2610d8a0c163cc97e8c95833.zip |
Allow 3-level DB configs to group connections by environment
[Arthur Nogueira Neves & Matthew Draper]
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/connection_specification.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/connection_specification.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb index dcf56997db..3e4ea28f63 100644 --- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb @@ -149,9 +149,18 @@ module ActiveRecord # Expands each key in @configurations hash into fully resolved hash def resolve_all config = configurations.dup + + if env = ActiveRecord::ConnectionHandling::DEFAULT_ENV.call + env_config = config[env] if config[env].is_a?(Hash) && !(config[env].key?("adapter") || config[env].key?("url")) + end + + config.reject! { |k, v| v.is_a?(Hash) && !(v.key?("adapter") || v.key?("url")) } + config.merge! env_config if env_config + config.each do |key, value| config[key] = resolve(value) if value end + config end |