aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_handling.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb
index 5141271db9..e3b59b8a22 100644
--- a/activerecord/lib/active_record/connection_handling.rb
+++ b/activerecord/lib/active_record/connection_handling.rb
@@ -109,12 +109,15 @@ module ActiveRecord
if database && role
raise ArgumentError, "connected_to can only accept a database or role argument, but not both arguments."
elsif database
- config_hash = resolve_config_for_connection(database)
- handler = lookup_connection_handler(database.to_sym)
-
- with_handler(database.to_sym) do
- handler.establish_connection(config_hash)
- return yield
+ database = { database => database } if database.is_a?(Symbol)
+ database.each do |role, database_key|
+ config_hash = resolve_config_for_connection(database_key)
+ handler = lookup_connection_handler(role.to_sym)
+
+ with_handler(role.to_sym) do
+ handler.establish_connection(config_hash)
+ return yield
+ end
end
elsif role
with_handler(role.to_sym, &blk)