gpt4 book ai didi

sinatra - Sinatra 事务回调警告中的 Activerecord

转载 作者:行者123 更新时间:2023-12-02 11:16:08 28 4
gpt4 key购买 nike

带有 activerecord gem 的 Sinatra 项目发出警告:

DEPRECATION WARNING: Currently, Active Record suppresses errors raised
within `after_rollback`/`after_commit` callbacks and only print 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.

You can opt into the new behavior and remove this warning by setting:


**config.active_record.raise_in_transactional_callbacks = true**

Gemfile.lock
activemodel (4.2.0)

activesupport (= 4.2.0)
builder (~> 3.1)

如何删除这个?谢谢!

编辑:小项目来了 https://gist.github.com/williamhqs/c127e5d7018aa61cb02a

最佳答案

错误消息告诉您该怎么做。在 Rails 中,暂时将此行添加到您的应用程序中:

config.active_record.raise_in_transactional_callbacks = true

在 Sinatra 中,您可以直接在 ActiveRecord::Base 上进行:
ActiveRecord::Base.raise_in_transactional_callbacks = true

请记住,此配置选项本身将在 Active Record 的下一个版本中被弃用。

关于sinatra - Sinatra 事务回调警告中的 Activerecord,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27862622/

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