Most developers use ActiveRecord callbacks after_create/after_update/after_destroy to generate background job, expire cache, etc., but they don’t realize these callbacks are still wrapped in database transaction, they probably got unexpected results like the app queued a job but the record is not created/updated(transaction rolled back).
For such situations after_commit callback should be used. after_commit is introduced from rails 3, if you use rails 2, there is a gem called after_commit(https://rubygems.org/gems/after_commit). after_rollback is another callback introduced in rails 3.
Here is the article with example.