Returns the connection currently associated with the class. This can also be used to "borrow" the connection to do database work unrelated to any of the specific Active Records.
Source Code
# File active_record/connection_adapters/abstract/connection_specification.rb, line 73 def connection if @active_connection_name && (conn = active_connections[@active_connection_name]) conn else # retrieve_connection sets the cache key. conn = retrieve_connection active_connections[@active_connection_name] = conn end end
<code/>and<pre/>for code samples.