aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2018-03-16 12:40:34 -0400
committereileencodes <eileencodes@gmail.com>2018-03-16 12:40:34 -0400
commit4027643f7f7eed9186d158fe5b1f21d0d6de8fe1 (patch)
treefc0a59bca8f6f2c782410b7b0bbfb5553202161c /railties
parent03929463192be49acfb3660160543e48b0960fd1 (diff)
downloadrails-4027643f7f7eed9186d158fe5b1f21d0d6de8fe1.tar.gz
rails-4027643f7f7eed9186d158fe5b1f21d0d6de8fe1.tar.bz2
rails-4027643f7f7eed9186d158fe5b1f21d0d6de8fe1.zip
Switch dbconsole config loader check
In a three-tier config environment `configurations[environment].presence` will return `{ :primary => { :key => value, :key => value }, :secondary => { :key => value, :key => value} }, which means it's not given a single config to connect to. If we flip these however it will connect to primary because that's the default connection, and on a two tier it will be `nil` so the code will select the connection from the configurations rather than the connection.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/commands/dbconsole/dbconsole_command.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb
index 8df548b5de..806b7de6d6 100644
--- a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb
+++ b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb
@@ -97,7 +97,7 @@ module Rails
elsif configurations[environment].blank? && configurations[connection].blank?
raise ActiveRecord::AdapterNotSpecified, "'#{environment}' database is not configured. Available configuration: #{configurations.inspect}"
else
- configurations[environment].presence || configurations[connection]
+ configurations[connection] || configurations[environment].presence
end
end
end