没有运算符匹配给定的名称和参数类型

我设置我的Rails 3.2.x应用程序以使用PostgreSQL HStore但我收到了一个错误。 看起来环境没有拾取hstore扩展。 我已经重新启动了我的机器,检查了数据库扩展等。

当我尝试执行时:

User.where("settings @> (:key => :value)", :key => "setting_x", :value => "test") 

我收到一个错误:( @>无法识别,即没有安装扩展名hstore ?)

 HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. 

我的Rails应用程序设置是:

Gemfile.rb:

 gem 'activerecord-postgres-hstore' 

移民:

 add_column :users, :settings, :hstore execute "CREATE INDEX CONCURRENTLY users_gin_settings ON users USING GIN(settings)" # can see the extenstion installed on my local dev psql database after this 

User模型:

 serialize :settings, ActiveRecord::Coders::Hstore 

动态User方法:

 # metaprogramming: has_setting_x + instance.setting_x %w[setting_x setting_y setting_z].each do |key| attr_accessible key # doesn't work > throws error because of the @> operator scope "has_#{key}", lambda { |value| where("settings @> (? => ?)", key, value) } # works: can use instance.setting_x define_method(key) do settings && settings[key] end # works: can use instance.setting_x = "value" define_method("#{key}=") do |value| self.settings = (settings || {}).merge(key => value) end end 

更新1:

当我直接与PostgreSQL DB对话时,这个工作原理:

 SELECT "users".* FROM "users" WHERE (settings @> hstore('setting_x','6D9Q7RO4SVWHXK86F')); 

Hstore文档说:

 The => operator is deprecated and may be removed in a future release. Use the hstore(text, text) function instead. 

所以,从它的外观来看,我的PostgreSQL数据库版本(9.2.1)已经弃用了=>表示法。 看起来我还有更多的研究。

来自PostgreSQL文档 :

=>运算符已弃用,可能会在将来的版本中删除。 请改用hstore(text, text)函数。

所以从它的角度来看,我的PG数据库版本(9.2.1)已经弃用了=>表示法。
现在在本地和Heroku工作。

例:

 User.where("settings @> hstore(?,?)", "setting_x", key)