在Rails 3中停用弃用警告 [英] Silencing Deprecation warnings in Rails 3
本文介绍了在Rails 3中停用弃用警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我如何在Rails 3中降低弃用警告吗?
Can anyone tell me how to silence deprecation warinings in Rails 3?
在某些情况下,它会引发误报。即使用-for从dynamic_form插件中获取haml和f.error_messages中的循环。
I have a few situations where it is throwing false positives. Namely using - for loops in haml and f.error_messages from the dynamic_form plugin.
谢谢
推荐答案
要使所有弃用警告均静音,您可以执行以下操作:
To silence all deprecation warnings you can do:
ActiveSupport::Deprecation.silenced = true
可以将其放置在特定环境的初始化程序或环境文件中(例如,仅在生产环境中静音)
This could be placed in an initializer or in the environment file for a specific environment (e.g. to silence only in production for example.)
或对于特定代码段,将其括在一个块中:
Or for a specific section of code, enclose it in a block:
ActiveSupport::Deprecation.silence do
# no warnings for any use of deprecated methods here
end
这对Rails 3& 4。
This works for both Rails 3 & 4.
这篇关于在Rails 3中停用弃用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文