Method: ActiveRecord::Transaction#after_commit
- Defined in:
- activerecord/lib/active_record/transaction.rb
#after_commit(&block) ⇒ Object
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.
85 86 87 88 89 90 91 |
# 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 |