instance method
after_commit
Ruby on Rails 8.1.2
Since v7.2.3Signature
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
-
blockblock
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