retrieve_connection(spec_name)
public
Locate the connection of the nearest super class. This can be an active or
defined connection: if it is the latter, it will be opened and set as the
active connection for the class it was defined for (not necessarily the
current class).
Show source
def retrieve_connection(spec_name)
pool = retrieve_connection_pool(spec_name)
unless pool
if ActiveRecord::Base.connection_handler != ActiveRecord::Base.default_connection_handler
raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found for the '#{ActiveRecord::Base.current_role}' role."
else
raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found."
end
end
pool.connection
end