Skip to content

Commit

Permalink
Only call DEFAULT_ENV proc one time
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca authored and matthewd committed Apr 8, 2014
1 parent d459f75 commit 2b6d1da
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions activerecord/lib/active_record/connection_handling.rb
Expand Up @@ -70,10 +70,13 @@ def resolve

private
def config
env = DEFAULT_ENV.call.to_s

cfg = Hash.new do |hash, key|
entry = @raw_config[key]
env_url = nil
if key.to_s == DEFAULT_ENV.call.to_s

if key.to_s == env
env_url = ENV["DATABASE_URL"]
end
env_url ||= ENV["DATABASE_URL_#{key.upcase}"]
Expand All @@ -83,7 +86,7 @@ def config
end

@raw_config.keys.each {|k| cfg[k] }
cfg[DEFAULT_ENV.call.to_s]
cfg[env]

cfg
end
Expand Down

0 comments on commit 2b6d1da

Please sign in to comment.