NoMethodError: undefined method `ignore' for Warning:Module

NoMethodError: undefined method `ignore' for Warning:Module

我无法找到此错误的任何解释,但是当我 运行ning 时: rake testbundle exec rake test 我得到:

NoMethodError: undefined method `ignore' for Warning:Module
/Users/przemyslaw/projects/writefully/config/initializers/warning.rb:4:in `block in <top (required)>'
/Users/przemyslaw/projects/writefully/config/initializers/warning.rb:3:in `each'
/Users/przemyslaw/projects/writefully/config/initializers/warning.rb:3:in `<top (required)>'
/Users/przemyslaw/projects/writefully/config/environment.rb:5:in `<top (required)>'
/Users/przemyslaw/projects/writefully/test/test_helper.rb:2:in `require'
/Users/przemyslaw/projects/writefully/test/test_helper.rb:2:in `<top (required)>'
/Users/przemyslaw/projects/writefully/test/controllers/comments_controller_test.rb:1:in `require'
/Users/przemyslaw/projects/writefully/test/controllers/comments_controller_test.rb:1:in `<top (required)>'
Tasks: TOP => test:run
(See full trace by running task with --trace)

我正在学习 codemy.net 上的教程,这个项目没有任何复杂或特别之处。我只生成了一个新的 rails 应用程序、几个模型和控制器,现在当我尝试 运行 测试时,它给了我这个错误。目前我的测试文件中没有单个测试,因此这与测试无关。警告文件中的 'ignore' 方法似乎存在一些问题:

config/initializers/warning.rb

# Rails will load this logic before booting up Rails server
unless Rails.env.development?
  Gem.path.each do |path|
    Warning.ignore(//, path)
  end
end

如有任何帮助或想法,我们将不胜感激。我正在使用 rails 4.2.10 和 ruby 2.5.8.

您似乎错过了安装 warning gem

我建议添加行

gem "warning"

您的 Gemfile 和 运行 bundler 在重新启动您的应用程序之前。