instance method
connection
Ruby on Rails 5.1.7
Last seen in v7.2.3.2Signature
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 cache keyed by a thread.
Source
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 375
def connection
@thread_cached_conns[connection_cache_key(@lock_thread || Thread.current)] ||= checkout
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb line 375
· View on GitHub
· Improve this page
· Find usages on GitHub