Closed noahsibai closed 7 years ago
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
<%= nested_form_for(@recipes) do |f| %> <%= render :partial=> 'form', :locals => {:f=>f} %>
<%= f.submit %> <% end %> <%= link_to "Back", recipes_path %>
Why wont it add a new fields_for?
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.submit %> <% end %> <%= link_to "Back", recipes_path %>
Why wont it add a new fields_for?