我的 Rails 应用程序中有一个嵌套表单模型。当我去编辑模型中的一个对象时,我的所有字段(text_area、check_box 等)都填充了数据库中的数据,除了选择框。当我使用表单编辑模型中的现有数据时,如何让我的选择框也被填充?
<%= form_for @test do |f| %>
<%= f.fields_for :questions do |builder| %>
<%= render 'question_fields', f: builder %>
<% end %>
<% end %>
_question_fields.html.erb
<fieldset>
<%= f.text_area :question_text %>
<%= f.select :correct_answer, options_for_select([['A', 1], ['B', 2], ['C', 3], ['D', 4], ['E', 5]]), :prompt => 'Choose the correct answer' %>
<%= f.check_box :question_check %>
</fieldset>