【问题标题】:How do i fix in ruby on rails the undefined method `alias_method_chain' error?如何在 ruby​​ on rails 中修复未定义的方法“alias_method_chain”错误?
【发布时间】:2019-08-21 21:04:44
【问题描述】:

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

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

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

浏览了几个解决方案帖子,我用 device 和 erubis 更新了我的 gem 商店,但仍然返回到那个 'alias_method_chain' 错误。

这是我的日志的 sn-p:

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 服务器从这里顺利运行。

【问题讨论】:

  • 为什么不将链接发布到您的 fork 以便我们看到您所做的更改?

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


【解决方案1】:

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

编辑:

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

【讨论】:

  • 好的,先生,我只是这样做了,但我仍然被同样的错误困扰:NoMethodError: undefined method `alias_method_chain' for ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class 你是说吗?别名方法
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-05
  • 1970-01-01
  • 2022-11-19
  • 1970-01-01
  • 2012-07-18
  • 1970-01-01
相关资源
最近更新 更多