Skip to content

Instantly share code, notes, and snippets.

@dreamwieber
Created April 7, 2012 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreamwieber/2332370 to your computer and use it in GitHub Desktop.
Save dreamwieber/2332370 to your computer and use it in GitHub Desktop.
Cocoon form
Here's what the form looks like:
<%= simple_form_for @album do |f| %>
<% if @album.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@album.errors.count, "error") %> prohibited this Album from being saved:</h2>
<ul>
<% @album.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions">
<%= f.label "name" %>
<%= f.text_field :name %>
<h2>Songs:</h2>
<div id="songs">
<%= f.simple_fields_for :songs do |event| %>
<%= render 'song_fields', :f=>event %>
<% end %>
<div class="links">
<%= link_to_add_association 'add event', f, :songs %>
</div>
</div>
<%= f.submit "#{@album.new_record? ? 'Create' : 'Update'} Album" %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment