use after_commit
Most developers use AR 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 errors on production servers. I wrote a post to suggest you that you should use after_commit for those callbacks that no need to execute in one transaction.
Post a comment