我该如何解决未定义方法“ alias_method_chain”错误的Ruby问题?

时间:2019-03-31 15:40:29

标签: ruby-on-rails ruby rubygems ruby-on-rails-5.1

我刚刚克隆了一个github repo https://github.com/maxitron93/p2pcollective.com,因为我在探索这个很棒的p2p借贷应用程序时遇到了错误

  

NoMethodError:ActiveRecord :: ConnectionAdapters :: PostgreSQLColumn:Class的未定义方法“ alias_method_chain”

同时迁移数据库或运行服务器。我正在使用cloud9 ide来避免我的PC环境。

在解决方案中,我用设备和erubis更新了我的gem商店,但仍然返回到“ alias_method_chain”错误。

这是我的日志的一部分:

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'

我希望我的Rails服务器从这里平稳运行。

1 个答案:

答案 0 :(得分:0)

alias_method_chain已在Rails 5中弃用并删除,但在此之前存在。似乎已安装的依赖项(可能是pg)不兼容。您也许可以使用bundle update pg解决问题,否则,可以使用更广泛的bundle update来解决问题。

编辑:

这是我喝咖啡之前上网的结果。负责的gem在您的堆栈跟踪中:activerecord-postgres-hstore,该链接不在您链接的项目中,这表明您进行了其他更改。对于Rails 4+,您不需要该宝石。 More info here