ActiveSupport::Deprecation.silenced = true does not works for me?

北战南征 提交于 2019-12-10 16:14:01

问题


My app was developed using Ruby 1.8.7 and Rails 2.3.11.

I am getting lot of deprecation warning while running 'rake spec'

DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use   autoload_paths instead. (called from load_paths at /home/soundarapandian/.rvm/gems/ruby-1.8.7-p352/gems/desert-0.5.2/lib/desert/manager.rb:36)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead. (called from load_paths at /home/soundarapandian/.rvm/gems/ruby-1.8.7-p352/gems/desert-0.5.2/lib/desert/manager.rb:36)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead. (called from load_paths at /home/soundarapandian/.rvm/gems/ruby-1.8.7-p352/gems/desert-0.5.2/lib/desert/manager.rb:36)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead. (called from load_paths at /home/soundarapandian/.rvm/gems/ruby-1.8.7-p352/gems/desert-0.5.2/lib/desert/manager.rb:36)
config.load_paths is deprecated and removed in Rails 3, please use autoload_paths instead
config.load_paths= is deprecated and removed in Rails 3, please use autoload_paths= instead
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead. (called from load_paths at /home/soundarapandian/.rvm/gems/ruby-1.8.7-p352/gems/desert-0.5.2/lib/desert/manager.rb:36)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead. (called from load_paths at /home/soundarapandian/.rvm/gems/ruby-1.8.7-p352/gems/desert-0.5.2/lib/desert/manager.rb:36)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use 

I have tried adding

ActiveSupport::Deprecation.silenced = true 
#in config/environments/test.rb

But still I am getting the warnings.How can I disable it?

Thank you.


回答1:


Looks like it will be config.activesupport.deprecation = :silence in the next major release. See https://github.com/rails/rails/pull/5986.

Note that you could add

ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:silence] = Proc.new { |message, callstack| }

to your app now as @carlosantoniodasilva mentions in the middle of the comments to get the :silence behaviour.

Popping the stack, though, the eat-your-broccoli answer would be to fix the deprecation warnings by changing over your config.load_paths calls in config/application.rb and elsewhere to config.autoload_paths as the warnings suggest. Mwah mwah advice about ignoring warnings over the long term, etc.



来源:https://stackoverflow.com/questions/9126331/activesupportdeprecation-silenced-true-does-not-works-for-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!