更新时间:2023-01-26 19:08:39
是的,回调都是在一个事务包裹起来。
Yes, the callbacks are all wrapped up in a transaction.
基本上,以下将导致回退:
Basically, the following will cause a rollback:
before_save
返回false或类似的回调 before_save
或类似的回调 after_save的
或类似的回调(after_create)before_save
or similar callbacksbefore_save
or similar callbacksafter_save
or similar callbacks (after_create)下面不会导致回滚:
after_save的
返回false或类似的回调 after_commit
after_save
or similar callbacksafter_commit
如果你不想异常引起回滚,使用 after_commit
If you don't want an exception to cause a rollback, use after_commit