instance method
connection
Ruby on Rails 4.1.16
Since v2.2.3 Last seen in v7.2.3Signature
connection()
Retrieve the connection associated with the current thread, or call #checkout to obtain one if necessary.
#connection can be called any number of times; the connection is held in a hash keyed by the thread id.
Source
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 261
def connection
# this is correctly done double-checked locking
# (ThreadSafe::Cache's lookups have volatile semantics)
@reserved_connections[current_connection_id] || synchronize do
@reserved_connections[current_connection_id] ||= checkout
end
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb line 261
· View on GitHub
· Improve this page
· Find usages on GitHub