title: Using Rails Form Helpers with Serialized Custom Classes
body: <p>I'm trying to save a hash of options in a single DB field. The form is able to save the data to the DB but not able to retrieve it again when I go to edit it (e.g. all the other fields are prepopulated except for the wp_options fields). </p>
  
  <pre><code>class Profile &lt; ActiveRecord::Base  
   serialize :wp_options  
  end
  </code></pre>
  
  <p>This is my custom class:</p>
  
  <pre><code>class WP_Options
   attr_accessor :wp_name, :wp_desc, :wp_limit
  end
  </code></pre>
  
  <p>In my form:</p>
  
  <pre><code>&lt;%= form_for(@profile, :remote =&gt; true) do |f| %&gt;
   ...
     &lt;%= f.fields_for :wp_options do |wp_options| %&gt;
        &lt;%= wp_options.text_field :wp_name  %&gt;
     &lt;% end %&gt;
   ...
  </code></pre>
  
  <p>In my controller:</p>
  
  <pre><code>@profile = Profile.new(:wp_options =&gt; WP_Options.new)
  </code></pre>
  
  <p>In my DB column 'wp_options':</p>
  
  <pre><code>--- !map:ActiveSupport::HashWithIndifferentAccess 
  wp_name: Test  
  </code></pre>
  
  <p>Any advice would be really appreciated.</p>