Hey,
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).
class Profile < ActiveRecord::Base
serialize :wp_options
end
This is my custom class:
class WP_Options
attr_accessor :wp_name, :wp_desc, :wp_limit
end
In my form:
<%= form_for(@profile, :remote => true) do |f| %>
...
<%= f.fields_for :wp_options do |wp_options| %>
<%= wp_options.text_field :wp_name %>
<% end %>
...
In my controller:
@profile = Profile.new(:wp_options => WP_Options.new)
In my DB column 'wp_options':
--- !map:ActiveSupport::HashWithIndifferentAccess
wp_name: Test
Any advice would be really appreciated.