instance method after_rollback

Ruby on Rails 7.2.3

Since v7.2.3

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

Signature

after_rollback(&block)

Registers a block to be called after the transaction is rolled back.

If there is no currently open transactions, the block is not called. But if the transaction is finalized, attempting to register the callback raises ActiveRecord::ActiveRecordError.

If the transaction is successfully committed but has a parent transaction, the callback is automatically added to the parent transaction.

If the entire chain of nested transactions are all successfully committed, the block is never called.

If the transaction is already finalized, attempting to register a callback will raise ActiveRecord::ActiveRecordError.

Parameters

block block
Source
# File activerecord/lib/active_record/transaction.rb, line 107
    def after_rollback(&block)
      @internal_transaction&.after_rollback(&block)
    end

Defined in activerecord/lib/active_record/transaction.rb line 107 · 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