instance method implicit_persistence_transaction

Ruby on Rails edge

Since edge Private — implementation detail, not part of the public API

Signature

implicit_persistence_transaction(connection, &block)

Method called to execute persistence method operations (save, destroy, touch), creating a transaction on the provided connection.

Override this method to customize transaction behavior, for example to set a specific isolation level.

The connection parameter provides access to the current database connection, allowing conditional logic based on connection state (e.g., whether a transaction is already open). The block parameter contains the persistence operation to be executed.

Example skipping transaction creation if one is already open:

“‘ class Account < ApplicationRecord

private
  def implicit_persistence_transaction(connection, &block)
    if connection.transaction_open?
      yield
    else
      super
    end
  end

end “‘

Parameters

connection req
block block
Source
# File activerecord/lib/active_record/transactions.rb, line 626
      def implicit_persistence_transaction(connection, &block)
        connection.transaction(&block)
      end

Defined in activerecord/lib/active_record/transactions.rb line 626 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Transactions

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close