加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 什么原因导致deprecation警告:ActiveRecord :

发布时间:2020-12-16 19:42:43 所属栏目:百科 来源:网络整理
导读:当我运行我的功能规格时,我收到此消息: DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated,has no effect and will be removed without replacement. 我正在使用Rails 5.0.0.rc1,我不知道是什么是抛出这种弃用警告
当我运行我的功能规格时,我收到此消息:

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之间添加的,作为一个不再适用于轨道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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读