本文介绍了弃用警告:不推荐使用 alias_method_chain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将项目升级到 Rails 5.当我运行 rspec
时,我收到警告
I upgraded the project to Rails 5. When I run rspec
I get a warning
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead.
From module, you can access the original method using super.
(called from <top (required)> at /home/alex/projects/myproject/config/application.rb:13)
application.rb 中的失败行是:
The failing line in application.rb is:
Bundler.require(*Rails.groups)
如何找出导致此弃用警告的原因以及如何消除错误?
How do I find out what is causing this deprecation warning and how to get rid of the error?
推荐答案
安装(除非已经安装)ack并在终端中运行:
Install (unless already installed) ack and run in the terminal:
ack alias_method_chain /Users/username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.1/gems/
它将指示使用 alias_method_chain
的所有位置(文件和代码行).
It will indicate all places where alias_method_chain
is used (files and code lines).
99% 的几率在您的一些宝石中使用它.
99% chance it is used in some of your gems.
请参阅我的回答,了解您可以执行的操作列表关于它.
See my answer for a list of things you can do about it.
这篇关于弃用警告:不推荐使用 alias_method_chain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!