<%%= form_for(@<%= singular_name %>) do |f| %>
  <%% if @<%= singular_name %>.errors.any? %>
  <div id="errorExplanation">
    <h2>The following errors prohibited this form from being saved:</h2>
    <ul>
    <%% @<%= singular_name %>.errors.full_messages.each do |msg| %>
      <li><%%= msg %></li>
    <%% end %>
    </ul>
  </div>
  <%% end %>

<% for attribute in attributes -%>
  <div class="field">
    <%%= f.label :<%= attribute.name %> %><br />
    <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
  </div>
<% end -%>
  <div class="actions">
    <%%= f.submit %>
  </div>
<%% end %>

<%%= form_for(@<%= singular_name %>) do |f| %>
  <%% if @<%= singular_name %>.errors.any? %>
  <div id="errorExplanation">
    <h2><%%= pluralize(@<%= singular_name %>.errors.count, "error") %> prohibited this <%= singular_name %> from being saved:</h2>
    <ul>
    <%% @<%= singular_name %>.errors.full_messages.each do |msg| %>
      <li><%%= msg %></li>
    <%% end %>
    </ul>
  </div>
  <%% end %>

<% for attribute in attributes -%>
  <div class="field">
    <%%= f.label :<%= attribute.name %> %><br />
    <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
  </div>
<% end -%>
  <div class="actions">
    <%%= f.submit %>
  </div>
<%% end %>

Use pluralize to properly inflect the number of errors.
Use pluralize to properly inflect the number of errors.
