instance method
with_connection
Ruby on Rails 8.1.2
Since v7.2.3Signature
with_connection(prevent_permanent_checkout: false, &block)
Checkouts a connection from the pool, yield it and then check it back in. If a connection was already leased via #lease_connection or a parent call to #with_connection, that same connection is yielded. If #lease_connection is called inside the block, the connection won’t be checked back in. If #connection is called inside the block, the connection won’t be checked back in unless the prevent_permanent_checkout argument is set to true.
Parameters
-
prevent_permanent_checkoutkey = false -
blockblock
Source
# File activerecord/lib/active_record/connection_handling.rb, line 312
def with_connection(prevent_permanent_checkout: false, &block)
connection_pool.with_connection(prevent_permanent_checkout: prevent_permanent_checkout, &block)
end
Defined in activerecord/lib/active_record/connection_handling.rb line 312
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionHandling