Postgres hstore和rails的语句无效

时间:2012-06-25 11:04:49

标签: ruby-on-rails postgresql rails-postgresql hstore

我正在使用带有rails 3.2的activerecord-postgres-hstore gem。我已经设置了hstore,当我尝试保存任何数据时,我收到错误:

ActiveRecord::StatementInvalid in ProductsController#create

PG::Error: ERROR:  Syntax error near 'a' at position 4
: INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at")      
VALUES ($1, $2, $3, $4, $5) RETURNING "id"

在这种情况下,我将'properties'定义为hstore数据类型。我已经在postgresl 8.4和9.1中看到了这个错误。任何信息赞赏。

1 个答案:

答案 0 :(得分:4)

Rails 3.2 Postgres Save Error "ActiveRecord::StatementInvalid: PG::Error: ERROR: Syntax error near 'T' at position 5"添加代码“serialize:data,ActiveRecord :: Coders :: Hstore”解决了我的问题。我最初尝试将其作为修复程序时,我的模型名称错误。