How to save a hash or json string into a jsonb field
<p>I have a json string from my active admin from <code>"{\"en\":\"Lorem\"}"</code></p>

<p>I want to save this in my <code>question.name</code> field, which is of postgres jsonb type.</p>

<pre><code>class Question &lt; ActiveRecord::Base
  serialize :name
end

# db/schema.rb
create_table "preset_questions", force: :cascade do |t|
  t.jsonb    "name",               default: {}
end
</code></pre>

<p>I've tried the following:</p>

<pre><code>question.update(name:"{\"en\":\"Lorem\"}")
question.update(name:JSON.parse("{\"en\":\"Lorem\"}"))
</code></pre>

<p>Result for both:</p>

<pre><code>question.name
=&gt; nil
</code></pre>