Method: ActiveRecord::ConnectionHandling#with_connection

Defined in:
activerecord/lib/active_record/connection_handling.rb

#with_connection(prevent_permanent_checkout: false, &block) ⇒ Object

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 yieled. 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.



295
296
297
# File 'activerecord/lib/active_record/connection_handling.rb', line 295

def with_connection(prevent_permanent_checkout: false, &block)
  connection_pool.with_connection(prevent_permanent_checkout: prevent_permanent_checkout, &block)
end