2012-01-17 30 views
3

我的應用程序是在Rails 2.3.11和Ruby 1.8.7p352中開發的。如何在鐵路2.3.11中禁用棄用日誌?

當我嘗試運行'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 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) 

如何在rails 2.3.11中禁用棄用日誌記錄?

+0

我在這裏問了一個類似的問題:http://stackoverflow.com/questions/5591509/suppress-ruby-warnings-when-running-specs – 2012-02-11 23:25:02

+2

是的,你可以做到這一點,或只是找到'load_paths'替換'autoload_paths '你就完成了。然後a)你的錯誤消失了,b)你從rails 3中棄用了-1。 – TomDunning 2012-02-17 14:44:30

+0

查看答案http://stackoverflow.com/questions/9126331/activesupportdeprecation-silenced-true-does-not-works-for-我 – 2012-04-30 16:03:07

回答

2

要關閉折舊警告,只需設置

ActiveSupport::Deprecation.silenced = true 

您也可以關閉特定代碼的警告,與

ActiveSupport::Deprecation.silence do 
    your_code_here 
end 
+1

這不在所提到的Rails版本中工作。 如果有人找答案,請訪問http://stackoverflow.com/questions/9126331/activesupportdeprecation-silenced-true-does-not-works-for-me – 2012-10-17 10:39:55

3

Rails 2.3.9 config.load_paths和.load_once_paths已更名爲配置.autoload_paths和.autoload_once_paths。一些插件(如Fckeditor)可能仍然使用舊版本。搜索load_paths並將其替換爲autoload_paths,然後錯誤應該消失。