简体   繁体   English

如何在 ruby​​ on rails 中修复未定义的方法“alias_method_chain”错误?

[英]How do i fix in ruby on rails the undefined method `alias_method_chain' error?

I have just cloned a github repo https://github.com/maxitron93/p2pcollective.com , as i was exploring this awesome p2p lending app i encountered an error我刚刚克隆了一个 github 存储库https://github.com/maxitron93/p2pcollective.com ,当我在探索这个很棒的 p2p 借贷应用程序时遇到了一个错误

NoMethodError: undefined method `alias_method_chain' for ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class NoMethodError:ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class 的未定义方法“alias_method_chain”

both when migrationg db or raunning server.无论是迁移数据库还是运行服务器时。 I'm using the cloud9 ide to avoid my pc environment.我正在使用 cloud9 ide 来避免我的电脑环境。

Running through a couple of solution posts, i updated my gem store with device and erubis but still returned back to that 'alias_method_chain' error.通过几个解决方案帖子,我用 device 和 erubis 更新了我的 gem 商店,但仍然返回到那个 'alias_method_chain' 错误。

Here's a snippet of my logs:这是我的日志片段:

rake db:migrate
rake aborted!
NoMethodError: undefined method `alias_method_chain' for ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class
Did you mean?  alias_method
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:80:in `<class:PostgreSQLColumn>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:74:in `<module:ConnectionAdapters>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:70:in `<module:ActiveRecord>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:2:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:256:in `block in load_dependency'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:662:in `new_constants_in'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:256:in `load_dependency'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/usr/local/rvm/gems/ruby-2.3.4/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/railties.rb:18:in `block (2 levels) in <class:Hstore>'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/usr/local/rvm/gems/ruby-2.3.4/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'

I expect my rails server to run smoothly from here.我希望我的 Rails 服务器从这里顺利运行。

alias_method_chain was deprecated and removed in Rails 5, but existed prior to that. alias_method_chain在 Rails 5 中已被弃用和删除,但在此之前就存在。 It looks like a dependency (possibly pg ) that has been installed is incompatible.看起来已安装的依赖项(可能是pg )不兼容。 You may be able to resolve the issue with bundle update pg , and if not, a broader bundle update should do the trick.您也许可以使用bundle update pg解决问题,如果没有,更广泛的bundle update应该可以解决问题。

EDIT:编辑:

This is what I get for internet'ing before coffee.这就是我在喝咖啡之前上网所得到的。 The gem responsible is in your stacktrace: activerecord-postgres-hstore , which isn't in the project you linked to, which suggests you've made other changes.负责的 gem 在您的堆栈跟踪中: activerecord-postgres-hstore ,它不在您链接到的项目中,这表明您已经进行了其他更改。 You don't need that gem for Rails 4+. Rails 4+ 不需要那个 gem。 More info here 更多信息在这里

In my case, I had gem 'foreigner package from Gemfile就我而言,我有Gemfile gem 'foreigner

  1. gem uninstall foreigner
  2. bundle install
  3. rails db:migrate

I hope it will be helpfull我希望它会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM