现在,此表单提交params
哈希,其中包含所有问题的questions
哈希值,以及包含所有答案的单独答案哈希值。我想更改表单,以便提交的params
哈希将包含包含所有问题的questions
哈希,并且每个问题本身都是包含自己<%= f.hidden_field "question[#{question_counter}]", value: question.content %>
的哈希(每个问题4个答案)。我该怎么做?
<%= form_for(:quiz_responses, url: quiz_responses_path) do |f| %>
<%= f.hidden_field :name, value: @survey.name %>
<% @questions.each do |question| %>
<ul>
<%= f.hidden_field "question[#{question_counter}]", value: question.content %>
<%= f.label question.content %>
<% question.answers.each do |answer| %>
<%= f.hidden_field "answer[#{answer_counter}]", value: answer.content %>
<% answer_counter += 1 %>
<%= f.label answer.content %>
<%= f.radio_button("user_answer[#{user_answer_counter}]", answer.content) %>
<% end %>
<% user_answer_counter += 1 %>
</ul>
<% question_counter += 1 %>
<% end #@questions.each do %>
<%= f.submit %>
<% end #form_for%>