Hi, I'm attempting to implement nested object forms for my site, using Ryan Daigle's blog post as a guide (http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes). For some reason, the nested form fields don't appear in the view.
class Instruction < ActiveRecord::Base
has_many :steps
accepts_nested_attributes_for :steps
end
class Step < ActiveRecord::Base
belongs_to :instruction
end
<% form_for @instruction do |instruction_form| %>
<%= instruction_form.error_messages %>
<p>
<%= instruction_form.label :title %><br />
<%= instruction_form.text_field :title %>
</p>
<p>
<%= instruction_form.label :difficulty %><br />
<%= instruction_form.text_field :difficulty %>
</p>
<% instruction_form.fields_for :steps do |step_form| %>
<%= step_form.label :explanation, 'Explanation: ' %>
<%= step_form.text_field :explanation %>
<% end %>
<p><%= instruction_form.submit "Submit" %></p>
<% end %>
When I change instruction_form.fields_for :steps do |step_form|
to instruction_form.fields_for :step do |step_form|
, the form renders but upon submission, I get an 'unknown attribute: step' error.
What I'm doing seems to match the tutorial. What should I check? Thanks.