When I cleck on <%= f.link_to_add "Add a Step", :steps %>, nothing happens.
noahsibai opened this issue · 0 comments
noahsibai commented
Recipe Model
class Recipe < ActiveRecord::Base
has_many :ingredients, :dependent => :destroy
has_many :steps, :dependent => :destroy
attr_accessible :title, :prep_time, :cook_time, :servings, :origin
accepts_nested_attributes_for :ingredients, :steps
end
Step Model
class Step < ActiveRecord::Base
belongs_to :recipe
attr_accessible :description, :sequence, :steps_attributes
end
New View
Creating a New Recipe
<%= nested_form_for(@recipes) do |f| %> <%= render :partial=> 'form', :locals => {:f=>f} %>
<%= f.fields_for :steps, :id => 'steps' do |s| %>
<%= render :partial=> 'step', :locals => {:s=>s} %>
<% end %>
<%= f.link_to_add "Add a Step", :steps %>
<%= f.fields_for :ingredients do |s| %>
<%= render :partial => "ingredient", :locals => {:s,s} %>
<% end %>
Why wont it add a new fields_for?