Method: ActiveRecord::ConnectionAdapters::ConnectionHandler#retrieve_connection

Defined in:
activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb

#retrieve_connection(connection_name, role: ActiveRecord::Base.current_role, shard: ActiveRecord::Base.current_shard) ⇒ Object

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).



191
192
193
194
# File 'activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb', line 191

def retrieve_connection(connection_name, role: ActiveRecord::Base.current_role, shard: ActiveRecord::Base.current_shard) # :nodoc:
  pool = retrieve_connection_pool(connection_name, role: role, shard: shard, strict: true)
  pool.lease_connection
end