MODEL:
class Listing < ActiveRecord::Base
serialize :details
validates_presence_of :name, :details
end
查看:
<% 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 %>
答案 0 :(得分:0)
您可以像这样使用fields_for:
<% 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 -%>