Skip to content

Instantly share code, notes, and snippets.

@seivan
Created March 31, 2009 02:29
Show Gist options
  • Save seivan/88015 to your computer and use it in GitHub Desktop.
Save seivan/88015 to your computer and use it in GitHub Desktop.
<h1>New post</h1>
<% @post.photos.build if @post.photos.empty? %>
<% form_for(@post) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :content %><br />
<%= f.text_area :content %>
</p>
<!-- :photos is a model that has paperclip on it.
I can use :image with the photomodel and it's action, but when trying to do a nested form
everything in Post.photos is nil except the timestamp -->
<% f.fields_for :photos, :html => { :multipart => true } do |picture| %>
<%= picture.label :image %>
<%= picture.file_field :image %>
<% end %>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', posts_path %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment