class ActiveRecord::Transaction

def after_commit(&block)

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

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

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

Registers a block to be called after the transaction is fully committed.
def after_commit(&block)
  if @internal_transaction.nil?
    yield
  else
    @internal_transaction.after_commit(&block)
  end
end