activerecord-postgres-hstore
activerecord-postgres-hstore copied to clipboard
undefined method simplified_type for class ActiveRecord::ConnectionAdapters::PostgreSQLColumn
I am using rails 5 and ruby 2.3.1. when i installed activerecord-postgres-hstore gem i got following error.
/activesupport-5.0.0.1/lib/active_support/core_ext/module/aliasing.rb:37:in alias_method': undefined method
simplified_type' for class ActiveRecord::ConnectionAdapters::PostgreSQLColumn' (NameError) from /activesupport-5.0.0.1/lib/active_support/core_ext/module/aliasing.rb:37:in
alias_method_chain'.
@sawantprasann you should be able to use hstore without this gem since Rails 4. Is there any particular reason to use it instead of the hstore built-in support?
I have the same issue:
- Rails: 5.0.0.1
- ruby: 2.3.1
- pg: 9.6.0
The issue appears when run:
$ rails g hstore:setup
Output:
/home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/core_ext/module/aliasing.rb:37:in `alias_method': undefined method `simplified_type' for class `ActiveRecord::ConnectionAdapters::PostgreSQLColumn' (NameError)
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/core_ext/module/aliasing.rb:37:in `alias_method_chain'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:80:in `<class:PostgreSQLColumn>'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:74:in `<module:ConnectionAdapters>'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:70:in `<module:ActiveRecord>'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/activerecord.rb:2:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activerecord-postgres-hstore-0.7.8/lib/activerecord-postgres-hstore/railties.rb:18:in `block (2 levels) in <class:Hstore>'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:in `each'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/base.rb:324:in `<module:ActiveRecord>'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/base.rb:24:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:345:in `active_record_configured?'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:263:in `disconnect_database'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:97:in `preload'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:143:in `serve'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:131:in `block in run'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:125:in `loop'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:125:in `run'
from /home/vagrant/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/vagrant/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
@Urielable @sawantprasann in Rails 5 you should not need this gem, since hstore is supported out of the box. Any particular reason to keep using it?
One reason we would like to use it is that the default return value for a null DB field is not nil
but {}
. We didn't like adding nil check access everywhere.
We could change the DB column default to ''
I guess, but we have some very large tables which will involve some very long running migrations.
Also it gives us nil
safe writes (no more "checking if the value is nil and having to create an empty hash before adding a key" operations).
yup removing the gem activerecord-postgres-hstore
did the trick
rails 4.2.8/ruby 2.4.2