更新时间:2023-01-26 19:18:19
是的,回调都包含在一个事务中.
Yes, the callbacks are all wrapped up in a transaction.
基本上,以下会导致回滚:
Basically, the following will cause a rollback:
before_save
或类似回调返回 falsebefore_save
或类似回调中的异常after_save
或类似回调(after_create)中的异常before_save
or similar callbacksbefore_save
or similar callbacksafter_save
or similar callbacks (after_create)以下不会导致回滚:
after_save
或类似回调返回 falseafter_commit
中的异常after_save
or similar callbacksafter_commit
如果您不希望异常导致回滚,请使用 after_commit
If you don't want an exception to cause a rollback, use after_commit