<%% form_for(@<%= singular_name %>) do |f| %>
  <%%= f.error_messages %>

  <fieldset>
    <legend><%%= t('<%= singular_name %>', :count => 1).humanize %></legend>

<% for attribute in attributes -%>
    <div>
      <%%= f.label :<%= attribute.name %>, t('<%= "attribute.#{attribute.column.name}" %>') %>
<% if attribute.name =~ /_id\Z/ -%>
<%
  association = attribute.name.sub(/_id\Z/, '')
  label_attribute = association.camelize.constantize.column_names.include?('name') ? 'name' : 'id'
-%>
      <%%= f.collection_select :<%= attribute.name %>, @<%= association.pluralize %>, :id, :<%= label_attribute %>,
        {:prompt => t('select_prompt')} %>
<% else -%>
      <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
<% end -%>
    </div>
<% end -%>

    <hr />
    <%%= f.submit t('save') %>
  </fieldset>
<%% end %>


<%% form_for(@<%= singular_name %>) do |f| %>
  <%%= f.error_messages %>

  <fieldset>
    <legend><%%= t('<%= singular_name %>', :count => 1).humanize %></legend>

<% for attribute in attributes -%>
    <div>
      <%%= f.label :<%= attribute.name %>, t('<%= "attribute.#{attribute.column.name}" %>') %>
<% if attribute.name =~ /_id\Z/ -%>
<%
  association = attribute.name.sub(/_id\Z/, '')
  label_attribute = association.camelize.constantize.column_names.include?('name') ? 'name' : 'id'
-%>
      <%%= f.collection_select :<%= attribute.name %>, @<%= association.pluralize %>, :id, :<%= label_attribute %>,
        {:prompt => t('select_prompt')} %>
<% elsif attribute.field_type == :date_select -%>
      <%%= f.text_field :<%= attribute.name %> %>
<% else -%>
      <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
<% end -%>
    </div>
<% end -%>

    <hr />
    <%%= f.submit t('save') %>
  </fieldset>
<%% end %>


Use text field for date selection
Use text field for date selection
