这是我的嵌套表格:
..
...
54 <div>
55 <h2> Address </h2>
56 <%= f.fields_for :address do |address_form| %>
57 <%= address_form.text_field :country %>
58 <% end %>
59 </div>
60
61 <div>
62 <h2> Participants </h2>
63 <%= f.fields_for :participants do |participant_form| %>
64 <%= participant_form.text_field :name %>
65 <%= participant_form.link_to_remove "Remove this participant" %>
66 <% end %>
67 <p><%= f.link_to_add "Add a participant", :participants %></p>
68 </div>
...
..
现在,当我访问我的模型/新页面时,它不会为地址或参与者呈现任何字段。
这是我的模型:
1 class CompetitionEntry < ActiveRecord::Base
2 has_many :participants
3 has_one :address
4 has_many :music_programs
5
6 accepts_nested_attributes_for :address
7
8 accepts_nested_attributes_for :participants, :music_programs,
9 :allow_destroy => true,
10 :reject_if => :all_blank
11 end
这是我的控制器:
16 def new
17 @competition_entry = CompetitionEntry.new
18 end
为什么会这样?我错过了什么?