Undefined hstore method for active recording

I am following Ryan Bates Rails 4 in episode 400 of Railscasts http://railscasts.com/episodes/400-what-s-new-in-rails-4 . It installs an application to use postgres (which I installed) with a hstore demo. He creates such a scaffold

rails g scaffold article name content:text published_on:date tags properties:hstore 

and during migration it

 execute "create extension hstore" create_table :articles do |t| t.string :name t.text :content t.date :published_on t.string :tags, array: true t.hstore :properties t.timestamps end 

However, when I performed this migration, I received the "hstore" error of the undefined method. Then I went into the test database and created the hstore extension, as shown below (and not in the migration file, as Ryan did)

 psql rails4test2_development psql (9.2.3) Type "help" for help. rails4test2_development=# CREATE EXTENSION hstore; 

But I got the same error when starting the migration.

 undefined method `hstore' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x007fa7ee7a9138>/Users/me/Sites/rails4test2/db/migrate/20130511204911_create_articles.rb:9:in `block in change' /Users/me/Sites/rails4test2/db/migrate/20130511204911_create_articles.rb:4:in `change' 

Can someone help me understand why this is not working for me?

+4
source share
2 answers

The problem was that although I installed the Rails 4 gem, the application still used Rails 3.2, which does not support hstore initially.

+4
source

I suspect this is a problem with many potential causes. For us, the pearl was seamless_database_pool.

https://github.com/bdurand/seamless_database_pool/issues/17

0
source

Source: https://habr.com/ru/post/1480288/


All Articles