gpt4 book ai didi

ruby-on-rails - 使用(restful)rails 时事务何时开始

转载 作者:数据小太阳 更新时间:2023-10-29 06:59:00 24 4
gpt4 key购买 nike

是否整个 restful 动词都在一个包罗万象的交易之下?也就是说,如果我在处理 UPDATE、DELETE 或 CREATE 操作的任何时候在验证或回调中引发错误,我可能在之前的回调中执行的每个数据库操作是否也回滚了?简而言之,在任何回调或验证时引发错误是否会导致该动词操作的数据库中根本没有发生任何变化?

最佳答案

Is it the case that the entire restful verb is under a single all encompassing transaction?

没有

if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled back?

没有。

does raising a Error on any callback or validation make it such that no change at all occurs in the database for that verb action?

没有。

如果您需要这种行为,您可以在您的 Controller 中显式创建事务(请参阅其他用户提供的示例),或者使用 around_filter 将该行为附加到您所有的 restful 操作。

关于ruby-on-rails - 使用(restful)rails 时事务何时开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/124396/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com