[英]DEPRECATION WARNING: alias_method_chain is deprecated
I upgraded the project to Rails 5. When I run rspec
I get a warning我将项目升级到 Rails 5。当我运行
rspec
我收到一条警告
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)
The failing line in application.rb is: application.rb 中的失败行是:
Bundler.require(*Rails.groups)
How do I find out what is causing this deprecation warning and how to get rid of the error?如何找出导致此弃用警告的原因以及如何消除错误?
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/
It will indicate all places where alias_method_chain
is used (files and code lines).它将指示使用
alias_method_chain
所有位置(文件和代码行)。
99% chance it is used in some of your gems. 99% 的几率在您的某些宝石中使用它。
See my answer for a list of things you can do about it.有关您可以做的事情的列表,请参阅我的回答。
In OSX, you can use:在 OSX 中,您可以使用:
grep -Ir alias_method_chain `bundle show rails`/..
And that will list all of the gems that use alias_method_chain
这将列出所有使用
alias_method_chain
的 gem
If the Gemfile is too large I would recommend to use the_silver_searcher to search for deprecated alias_method_chain because it is faster如果 Gemfile 太大,我建议使用the_silver_searcher来搜索已弃用的 alias_method_chain,因为它更快
ag alias_method_chain /path/to/gemset
I have gepgems
bash helper function to not type /path/to/gemset every time我有
gepgems
bash 辅助函数,每次都不会输入 /path/to/gemset
grepgems alias_method_chain
To use it add the following function to your .bash_profile (or somewhere else in the dotfiles you like)要使用它,请将以下函数添加到您的 .bash_profile(或您喜欢的点文件中的其他位置)
function grepgems() {
ag $1 $GEM_HOME"/gems"
}
Solution for docker :码头工人的解决方案:
docker exec -it [CONTAINER_NAME] /bin/bash
docker exec -it [CONTAINER_NAME] /bin/bash
apt-get install silversearcher-ag
apt-get install silversearcher-ag
ag alias_method_chain $GEM_HOME"/gems"
ag alias_method_chain $GEM_HOME"/gems"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.