lundi 20 avril 2015

Error when modifying Postgres JSON field in Rails 3.2

I'm trying to use the JSON (Postgres 9.3, so not JSONB) field type in my Rails 3.2 application.

I've created the field with the following migration without a problem:

def change
  add_column :blocks, :meta, :json

However, when I'm trying to modify the field like this:

b.meta = {name: "John"}

I'm getting the following error:

ActiveRecord::StatementInvalid: PGError: ERROR:  invalid input syntax for type json
LINE 1: UPDATE "blocks" SET "meta" = '---

I'm not even sure if JSON type is supported in Rails 3.2 but I've seen some posts talking about it as possible (though no details on how it works).

Aucun commentaire:

Enregistrer un commentaire