diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-04-26 23:13:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 23:13:59 -0700 |
commit | 28cd12c3454338450c6a505ae9997380065367c8 (patch) | |
tree | c350dcd01f313585b1efaa277ab95222df2d0112 /railties/lib | |
parent | 1583e260f9278986f3c4ea3702c081727838c290 (diff) | |
parent | dfc361df364c0c01a244355fe39f5871fb5b00f9 (diff) | |
download | rails-28cd12c3454338450c6a505ae9997380065367c8.tar.gz rails-28cd12c3454338450c6a505ae9997380065367c8.tar.bz2 rails-28cd12c3454338450c6a505ae9997380065367c8.zip |
Merge pull request #28896 from pschambacher/load_with_shared
Added a shared section to config/database.yml that will be loaded for all envs
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 7c49fabba5..27c1572357 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -133,7 +133,14 @@ module Rails config = if yaml && yaml.exist? require "yaml" require "erb" - YAML.load(ERB.new(yaml.read).result) || {} + loaded_yaml = YAML.load(ERB.new(yaml.read).result) || {} + shared = loaded_yaml.delete("shared") + if shared + loaded_yaml.each do |_k, values| + values.reverse_merge!(shared) + end + end + Hash.new(shared).merge(loaded_yaml) elsif ENV["DATABASE_URL"] # Value from ENV['DATABASE_URL'] is set to default database connection # by Active Record. |