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

mwi*_*ena 5 ruby rubygems ruby-on-rails ruby-on-rails-5.1

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

NoMethodError:未定义 ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class 的方法 `alias_method_chain'

无论是在迁移数据库还是运行服务器时。我正在使用 cloud9 ide 来避开我的电脑环境。

通过几个解决方案帖子,我用设备和 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'
Run Code Online (Sandbox Code Playgroud)

我希望我的 rails 服务器能够从这里顺利运行。

cor*_*ard 6

alias_method_chain在 Rails 5 中被弃用和删除,但在此之前存在。看起来pg已经安装的依赖项(可能)不兼容。您或许可以使用 来解决问题bundle update pg,否则,bundle update应该使用更广泛的方法来解决问题。

编辑:

这就是我在喝咖啡之前上网所得到的。负责的 gem 位于您的 stacktrace: 中activerecord-postgres-hstore,它不在您链接到的项目中,这表明您进行了其他更改。Rails 4+ 不需要那个 gem。更多信息在这里