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

让人想犯罪 __ 提交于 2020-01-15 05:34:06

问题


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

NoMethodError: undefined method `alias_method_chain' for ActiveRecord::ConnectionAdapters::PostgreSQLColumn:Class

both when migrationg db or raunning server. I'm using the cloud9 ide to avoid my pc environment.

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.

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.


回答1:


alias_method_chain was deprecated and removed in Rails 5, but existed prior to that. It looks like a dependency (possibly pg) that has been installed is incompatible. You may be able to resolve the issue with bundle update pg, and if not, a broader bundle update should do the trick.

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. You don't need that gem for Rails 4+. More info here



来源:https://stackoverflow.com/questions/55442564/how-do-i-fix-in-ruby-on-rails-the-undefined-method-alias-method-chain-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!