Skip to content

Instantly share code, notes, and snippets.

@jdkealy
Created August 17, 2011 03:05
Show Gist options
  • Save jdkealy/1150730 to your computer and use it in GitHub Desktop.
Save jdkealy/1150730 to your computer and use it in GitHub Desktop.
MAIN FORM
<%= form_for(@project) do |f| %>
<% if @project.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2>
<ul>
<% @project.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :diagram %>
<%= f.file_field :diagram %>
</div>
<div class="field">
<% if(@project.photo) %>
<%= image_tag @project.photo %>
<br />
<% end %>
<%= f.label :photo %>
<%= f.file_field :photo %>
</div>
<div class="field">
<%= f.fields_for :galleries do |builder| %>
<%= builder %>
<%= render "gallery_fields", :f => builder %>
<% end %>
<p><%= link_to_add_fields "Add Image", f, :galleries %></p>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
PARTIAL
<div class="field">
<%#= link_to 'Destroy', project, confirm: 'Are you sure?', method: :delete %>
<%= #nothing @gallery %>
<%= #error gallery %>
<%= #f %>
<%= params %>
<%= f.label :photo %>
<%= f.file_field :photo %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment