diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index 84dde1b14f..a73ce02104 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -130,12 +130,13 @@ module ActiveRecord # can be used as argument for establish_connection, for easy # re-establishing of the connection. def self.remove_connection(klass=self) - conn = @@defined_connections[klass.name] - @@defined_connections.delete(klass.name) - @@connection_cache[Thread.current.object_id].delete(klass.name) - active_connections.delete(klass.name) - @connection = nil - conn.config if conn + spec = @@defined_connections[klass.name] + konn = active_connections[klass.name] + @@defined_connections.delete_if { |key, value| value == spec } + @@connection_cache[Thread.current.object_id].delete_if { |key, value| value == konn } + active_connections.delete_if { |key, value| value == konn } + konn.disconnect! if konn + spec.config if spec end # Set the connection for the class. |