title: Rails serialization not dumping hash correctly
body: <p>I have an active record model that has a column called <code>configuration</code> of type text. That column is serialized with a custom class, like so:</p>
  
  <pre><code>class MyModel &lt; ApplicationRecord
    serialize :configuration, MySerializer
  end
  </code></pre>
  
  <p>The class <code>MySerializer</code> has the following class methods:</p>
  
  <pre><code>def dump(configuration)
    configuration.to_json if configuration
  end
  
  def load(configuration)
    obj = new
    obj.json_hash = JSON.parse(configuration) if configuration.present?
    obj
  end
  </code></pre>
  
  <p>This instantiates an instance of the class <code>MySerializer</code> with the attr accessor <code>json_hash</code>.</p>
  
  <p>Now, here's the problem, I'm doing:</p>
  
  <p><code>MyModel.create(configuration: {"key" =&gt; 1})</code></p>
  
  <p>And once I do <code>MyModel.first</code>, i get this:</p>
  
  <pre><code>...
  configuration:
    #&lt;MySerializer:0x00000007faa558
     @json_hash={"json_hash"=&gt;{"key" =&gt; 1}
  </code></pre>
  
  <p>I was expecting getting something like:</p>
  
  <pre><code>@json_hash = {"key" =&gt; 1}
  </code></pre>
  
  <p>Any idea why I'd get the repeated key <code>json_hash</code> inside the attr accessor <code>@json_hash</code> ?</p>
  
  <p>Thanks!</p>