aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-24 07:01:43 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-24 07:01:43 +0000
commit2b28575734f557ee61a7544e17bd3510eaa6d900 (patch)
treef488e4c413298f86a041ca8de3e87ccbb4f37101 /activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
parent52325f6bf868c5efa80fbcf06d139a31816251fb (diff)
downloadrails-2b28575734f557ee61a7544e17bd3510eaa6d900.tar.gz
rails-2b28575734f557ee61a7544e17bd3510eaa6d900.tar.bz2
rails-2b28575734f557ee61a7544e17bd3510eaa6d900.zip
Reloading a model doesn't lose track of its connection. References #2996.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3182 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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.rb16
1 files changed, 8 insertions, 8 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 5e70930a85..5ef200fd97 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
@@ -68,7 +68,7 @@ module ActiveRecord
raise AdapterNotSpecified unless defined? RAILS_ENV
establish_connection(RAILS_ENV)
when ConnectionSpecification
- @@defined_connections[self] = spec
+ @@defined_connections[name] = spec
when Symbol, String
if configuration = configurations[spec.to_s]
establish_connection(configuration)
@@ -101,11 +101,11 @@ module ActiveRecord
klass = self
ar_super = ActiveRecord::Base.superclass
until klass == ar_super
- if conn = active_connections[klass]
+ if conn = active_connections[klass.name]
# Validate the active connection before returning it.
conn.verify!
return conn
- elsif conn = @@defined_connections[klass]
+ elsif conn = @@defined_connections[klass.name]
# Activate this connection specification.
klass.connection = conn
return self.connection
@@ -119,7 +119,7 @@ module ActiveRecord
def self.connected?
klass = self
until klass == ActiveRecord::Base.superclass
- if active_connections[klass]
+ if active_connections[klass.name]
return true
else
klass = klass.superclass
@@ -133,9 +133,9 @@ 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]
- @@defined_connections.delete(klass)
- active_connections[klass] = nil
+ conn = @@defined_connections[klass.name]
+ @@defined_connections.delete(klass.name)
+ active_connections[klass.name] = nil
@connection = nil
conn.config if conn
end
@@ -143,7 +143,7 @@ module ActiveRecord
# Set the connection for the class.
def self.connection=(spec)
if spec.kind_of?(ActiveRecord::ConnectionAdapters::AbstractAdapter)
- active_connections[self] = spec
+ active_connections[name] = spec
elsif spec.kind_of?(ConnectionSpecification)
self.connection = self.send(spec.adapter_method, spec.config)
elsif spec.nil?