Skip to content

Instantly share code, notes, and snippets.

@mauriciofierrom
Created June 8, 2012 22:37
Show Gist options
  • Save mauriciofierrom/2898482 to your computer and use it in GitHub Desktop.
Save mauriciofierrom/2898482 to your computer and use it in GitHub Desktop.
Nested Form Issues
<%= form_for(@person) do |f| %>
<% if @person.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@person.errors.count, "error") %> prohibited this person from being saved:</h2>
<ul>
<% @person.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :last %><br />
<%= f.text_field :last %>
</div>
<div class="field">
<%= f.label :birthdate %><br />
<%= f.date_select :birthdate %>
</div>
<div class="field">
<%= f.label :address %><br />
<%= f.text_area :address %>
</div>
<div class="field">
<%= f.label :mobile %><br />
<%= f.text_field :mobile %>
</div>
<div class="field">
<%= f.label :phone %><br />
<%= f.text_field :phone %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<% f.fields_for :user do |u| %>
<div class="field">
<%= u.label :user %><br />
<%= u.text_field :user %>
</div>
<div class="field">
<%= u.label :password %><br />
<%= u.text_field :password %>
</div>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment