views:

19

answers:

1

MODEL:

class Listing < ActiveRecord::Base
  serialize :details
  validates_presence_of :name, :details
end

VIEW:

<% form_for(@listing) do |f| %>
  <div class="text_field">
    <%= f.label :name, "Name" %><br />
    <%= f.text_field :name, :autocomplete => "off" %>  
  </div>
  <!-- CUSTOM DETAILS HERE! -->
<% end %>
A: 

You can use fields_for like so:

<% fields_for "listing[details]", listing.details do |detail_fields| -%>
  <div class="text_field">
    <%= detail_fields.label :phone_number, "Phone Number" %><br />
    <%= detail_fields.text_field :phone_number %>  
  </div>
  <!-- MORE CUSTOM FIELDS HERE -->
<% end -%>