Callbacks

suggest change

There 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents