Rails 4.0.1, and I really don't understand what I am doing wrong here. I have a model ChallengeList and a model Challenge. ChallengeList has many Challenges:
#ChallengeList
has_many :challenges, :dependent => :destroy
accepts_nested_attributes_for :challenges
I want to make a nested form that allows the user to update challenges while editing a list (code in HAML, but should make sense):
= form_for @challenge_list do |f|
.field
= f.label :title, "Title (optional)"
%br/
= f.text_field :title
-# etc, fields for challenge list
="#{@challenge_list.challenges.length} challenges"
-f.fields_for :challenges do |builder|
.field
= builder.text_field :description
%br/
.actions
= f.submit 'Save'
But when I try out my form, the field_for section doesn't show anything, even if @challenge_list contains more than 1 challenge. (e.g. challenge_list.challenges.length turns up a number >0).
Am I missing something?