Callbacks
suggest changeThere are two types of callbacks associated with committing and rolling back transactions: after_commit and after_rollback.
after_commit callbacks are called on every record saved or destroyed within a transaction immediately after the transaction is committed. after_rollback callbacks are called on every record saved or destroyed within a transaction immediately after the transaction or savepoint is rolled back.
These callbacks are useful for other systems because they run only after the database has reached a permanent state. after_commit is a good place to clear a cache. Clearing it inside the transaction can rebuild the cache before the database is updated.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents