更新时间:2023-01-26 19:08:45
after_create 是保存当前模型的事务的一部分.因此,如果您的代码崩溃或 after_create 返回 false,它应该回滚当前事务并使 enrollment
保存无效.
after_create is a part of the transaction saving the current model. Therefore, if your code crashes or if after_create returns false, it should rollback the current transaction and invalidate the enrollment
saving.
如果你想模拟这个,把它添加到你的 after_create 中,看看是否一切都按预期工作:
If you want to simulate this, add this to your after_create and see if everything works as expected :
raise Exception.new("CRASH")