Skip to content

Instantly share code, notes, and snippets.

@smooki
Created January 13, 2012 15:27
Show Gist options
  • Save smooki/1606966 to your computer and use it in GitHub Desktop.
Save smooki/1606966 to your computer and use it in GitHub Desktop.
:buffet_drinks undefined variable error ...
<%= nested_form_for [event, buffet] do |f| %>
<% if buffet.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(buffet.errors.count, "error") %>
prohibited this buffet from being saved:
</h2>
<ul>
<% :buffet.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<h2>Drinks</h2>
<%= f.fields_for :buffet_drinks do |drink_form| %>
<p>
<%= drink_form.label :qty %>
<%= drink_form.text_field :qty %>
<%= drink_form.collection_select(:drink_id, Drink.all, :id, :name) %>
<%= drink_form.link_to_remove "remove" %>
</p>
<% end %>
<p><%= f.link_to_add "Add", :buffet_drinks %></p>
<h2>Foods</h2>
<%= f.fields_for:buffet_foods do |food_form| %>
<p>
<%= food_form.label :qty %>
<%= food_form.text_field :qty %>
<%= food_form.collection_select(:food_id, Food.all, :id, :name) %>
<%= food_form.link_to_remove "remove" %>
</p>
<% end %>
<p><%= f.link_to_add "Add", :buffet_foods %></p>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
<%= nested_form_for [event, buffet] do |f| %>
<% if buffet.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(buffet.errors.count, "error") %>
prohibited this buffet from being saved:
</h2>
<ul>
<% :buffet.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<h2>Drinks</h2>
<%= f.fields_for :buffet_drinks do |drink_form| %>
<p>
<%= drink_form.label :qty %>
<%= drink_form.text_field :qty %>
<%= drink_form.collection_select(:drink_id, Drink.all, :id, :name) %>
<%= drink_form.link_to_remove "remove" %>
</p>
<% end %>
<p><%= f.link_to_add "Add", :buffet_drinks %></p>
<h2>Foods</h2>
<%= f.fields_for:buffet_foods do |food_form| %>
<p>
<%= food_form.label :qty %>
<%= food_form.text_field :qty %>
<%= food_form.collection_select(:food_id, Food.all, :id, :name) %>
<%= food_form.link_to_remove "remove" %>
</p>
<% end %>
<p><%= f.link_to_add "Add", :buffet_foods %></p>
<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