diogob / activerecord-postgres-hstore

Goodbye serialize, hello hstore. Speed up hashes in the database.
MIT License
836 stars 106 forks source link

Me or a need for an update to the README? #36

Closed envygeeks closed 11 years ago

envygeeks commented 12 years ago

Rails: 3.2.6. I had to use the serializer on the gem from rubygems.org even though the README implies that you would only need to do that if you are using the 'development' version. Do we always need to use the serializer now? If so perhaps a documentation update?

The model that tripped me up for a minute at first:

class Page < ActiveRecord::Base
  validates_presence_of(:type, :data); belongs_to(:user, readonly: true)
end

It was a simple model, yes it was using a OpenStruct or SuperStruct (my own beefed up custom version of OpenStruct) but I had added [to|from]_hstore to work around potential issues... Even when I was working with a raw hash I would always get:

INSERT INTO "pages" ("data", "type") VALUES ($1, $2) RETURNING "id" [["data", {"slug"=>"Test"}], ["type", "page"]] ActiveRecord::StatementInvalid: PG::Error: ERROR: Syntax error near 's' at position 4

That is, until I implemented the serializer and it started turning it properly.

tadast commented 12 years ago

You are right, this started happening some time between 0.3.0 and 0.4.0

diogob commented 11 years ago

Updated the README to comply with the new 0.7 (which provides only the custom serializer)