instance method after_commit

Ruby on Rails 7.2.3

Since v7.2.3

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

Signature

after_commit(&block)

Registers a block to be called after the transaction is fully committed.

If there is no currently open transactions, the block is called immediately, unless the transaction is finalized, in which case attempting to register the callback raises ActiveRecord::ActiveRecordError.

If the transaction has a parent transaction, the callback is transferred to the parent when the current transaction commits, or dropped when the current transaction is rolled back. This operation is repeated until the outermost transaction is reached.

If the callback raises an error, the transaction remains committed.

Parameters

block block
Source
# File activerecord/lib/active_record/transaction.rb, line 85
    def after_commit(&block)
      if @internal_transaction.nil?
        yield
      else
        @internal_transaction.after_commit(&block)
      end
    end

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

Defined in ActiveRecord::Transaction

Type at least 2 characters to search.

↑↓ navigate · open · esc close