Sinatra 事务回调警告中的 Activerecord
Activerecord in Sinatra transactional callbacks warning
具有 activerecord 的 Sinatra 项目 gem 发出警告:
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 版本中弃用。
Patrick 是对的,要删除警告并转到新行为,您应该添加
Rails : config.active_record.raise_in_transactional_callbacks = true
西纳特拉: ActiveRecord::Base.raise_in_transactional_callbacks = true
我认为了解一下它到底做了什么很重要:
https://github.com/rails/rails/pull/16537 and https://github.com/rails/rails/pull/14488
after_commit / after_rollback 的实际行为: 当出现错误时,错误会被记录下来,但不会被浅化。意味着错误不会停止当前执行。
after_commit / after_rollback 的未来行为: 当出现错误时,错误会被记录下来并且不会被浅化。这意味着该错误将停止当前执行。
此处显示的警告只是为了通知您未来的行为,并且此警告将在 Rails / ActiveRecord 的未来版本中删除。
具有 activerecord 的 Sinatra 项目 gem 发出警告:
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 版本中弃用。
Patrick 是对的,要删除警告并转到新行为,您应该添加
Rails : config.active_record.raise_in_transactional_callbacks = true
西纳特拉: ActiveRecord::Base.raise_in_transactional_callbacks = true
我认为了解一下它到底做了什么很重要: https://github.com/rails/rails/pull/16537 and https://github.com/rails/rails/pull/14488
after_commit / after_rollback 的实际行为: 当出现错误时,错误会被记录下来,但不会被浅化。意味着错误不会停止当前执行。
after_commit / after_rollback 的未来行为: 当出现错误时,错误会被记录下来并且不会被浅化。这意味着该错误将停止当前执行。
此处显示的警告只是为了通知您未来的行为,并且此警告将在 Rails / ActiveRecord 的未来版本中删除。