instance method with_connection

Ruby on Rails 7.2.3

Since v7.2.3

Available in: v7.2.3 v8.0.4 v8.1.2

Signature

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

Parameters

prevent_permanent_checkout key = false
block block
Source
# File activerecord/lib/active_record/connection_handling.rb, line 297
    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 297 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionHandling

Type at least 2 characters to search.

↑↓ navigate · open · esc close