I have a json string from my active admin from "{\"en\":\"Lorem\"}"
I want to save this in my question.name field, which is of postgres jsonb type.
class Question < ActiveRecord::Base
serialize :name
end
# db/schema.rb
create_table "preset_questions", force: :cascade do |t|
t.jsonb "name", default: {}
end
I've tried the following:
question.update(name:"{\"en\":\"Lorem\"}")
question.update(name:JSON.parse("{\"en\":\"Lorem\"}"))
Result for both:
question.name
=> nil