gpt4 book ai didi

ruby-on-rails - 是什么导致弃用警告:ActiveRecord::Base.raise_in_transactional_callbacks=?

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

我在运行功能规范时收到此消息:

DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement.

我正在使用 Rails 5.0.0.rc1,我不确定是什么引发了这个弃用警告。

我的 application.rb 文件中有这个。我删除了它,弃用警告消失了:

config.active_record.raise_in_transactional_callbacks = true

我想了解此弃用警告的实际含义以及触发此弃用警告的原因。

最佳答案

我相信这种行为是在 4.1 和 4.2 之间添加的,作为对 rails 5 不再相关的问题的临时解决方案:

http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#error-handling-in-transaction-callbacks

Currently, Active Record suppresses errors raised within after_rollback or after_commit callbacks and only prints them to the logs. In the next version, these errors will no longer be suppressed. Instead, the errors will propagate normally just like in other Active Record callbacks.

When you define an after_rollback or after_commit callback, you will receive a deprecation warning about this upcoming change. When you are ready, you can opt into the new behavior and remove the deprecation warning by adding following configuration to your config/application.rb:

config.active_record.raise_in_transactional_callbacks = true

为了澄清,@pixelearth 表示我在下面的评论不够清晰/突出。在 Rails 5 及更高版本中,从 config/application.rb 中删除以下行:

config.active_record.raise_in_transactional_callbacks = true

关于ruby-on-rails - 是什么导致弃用警告:ActiveRecord::Base.raise_in_transactional_callbacks=?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37464966/

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