很难解释我的问题,所以我会发布相关的代码,希望这会更有意义。
我有一张表格,其中包含第二种表格。
_form.html.haml:
= form_for @question, :html => { :class => "form-horizontal" } do |f|
...
%h3 Parts
%ul
= f.fields_for :question_parts, @question.question_parts do |builder|
= render 'question_part_fields', f: builder
= link_to_add_fields 'Add Part', f, :question_parts
.form-group
.col-sm-offset-2.col-sm-10
= f.submit :class => 'btn btn-primary'
_question_part_fields.html.haml:
%li.question_parts
.......
= f.fields_for :correct_answer do |builder|
= render 'correct_answer_fields', f: builder
.form-group
.col-sm-offset-2.col-sm-10
= f.hidden_field :_destroy
= link_to 'Remove Part', '#', class: 'remove_fields'
%hr
_correct_answer_fields.html.haml:
.form-group
= f.label :correct_answer, :class => 'col-sm-2 control-label'
.col-sm-10
%h5 Raw (text, ASCIImath)
= f.text_area :content, :class => 'form-control'
%h5 Preview
#answer_preview
问题在于,当我加载表单时,所有不同的部分都正确加载,但是当我单击"添加部件"时,它会呈现_questions_part_fields,而不是_correct_answer_fields。
为什么会出现这种情况以及如何解决这个问题?
由于