instance method
with_connection
Ruby on Rails 6.0.6
Since v2.2.3Signature
with_connection()
If a connection obtained through #connection or #with_connection methods already exists yield it to the block. If no such connection exists checkout a connection, yield it to the block, and checkin the connection when finished.
Source
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 466
def with_connection
unless conn = @thread_cached_conns[connection_cache_key(Thread.current)]
conn = connection
fresh_connection = true
end
yield conn
ensure
release_connection if fresh_connection
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb line 466
· View on GitHub
· Improve this page
· Find usages on GitHub