From 5167b8f7ffa66c8772c455916b8418844e3b4674 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Sat, 7 May 2016 12:25:37 -0500 Subject: Move establish_connection to handler --- .../connection_adapters/abstract/connection_pool.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index f437dafec2..c124f1c4b5 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -837,7 +837,15 @@ module ActiveRecord end alias :connection_pools :connection_pool_list - def establish_connection(spec) + def establish_connection(spec_or_config, name: "primary") + if spec_or_config.is_a?(ConnectionSpecification) + spec = spec_or_config + else + resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new(ActiveRecord::Base.configurations) + spec = resolver.spec(spec_or_config, name) + end + + remove_connection(spec.name) owner_to_pool[spec.name] = ConnectionAdapters::ConnectionPool.new(spec) end -- cgit v1.2.3