Just wanted to let you know I had some issues getting this setup when using a Postgres jsonb column...
My first implementation did not include a custom coder, and when updating a typed_store attribute, I got this error:
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for type json
DETAIL: Token "-" is invalid.
CONTEXT: JSON data, line 1: -...
: UPDATE "companies" SET "settings" = $1, "updated_at" = $2 WHERE "companies"."id" = $3
Which is because it was using the default yaml coder.
However, when I added the DumbCoder, I got a TypeError: can't cast Hash to error.
It was all solved by just using the JSON coder:
typed_store :settings, coder: JSON do |s|
s.boolean :foo, default: true, null: false
end
I think this would be useful to add to the readme...
Cheers!
Just wanted to let you know I had some issues getting this setup when using a Postgres jsonb column...
My first implementation did not include a custom coder, and when updating a typed_store attribute, I got this error:
Which is because it was using the default yaml coder.
However, when I added the
DumbCoder, I got aTypeError: can't cast Hash toerror.It was all solved by just using the JSON coder:
I think this would be useful to add to the readme...
Cheers!