Skip to content

Instantly share code, notes, and snippets.

@sapient
Created November 11, 2011 21:54
Show Gist options
  • Save sapient/1359429 to your computer and use it in GitHub Desktop.
Save sapient/1359429 to your computer and use it in GitHub Desktop.
Most recent form
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :title %>
<br/>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :content %>
<br/>
<%= f.text_area :content %>
</div>
<div class="field">
<%= f.label :category %>
<br/>
<%= f.text_field :category %>
</div>
<div class="field">
<%= f.fields_for :attachments do |attach| %> <br>
<%= attach.file_field :photo %> <br>
<%= attach.collection_select :category_id, AttachmentCategory.all, :id, :name %>
<% end %>
<br>
</div>
<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