Rails radio buttons not working properly and related issues
<p>I created three models, "Survey", "Question", and "Answer". Survey has_many Questions which has_many Answers (and they all belong to the model above them).</p>

<p>This is the form I want to display the questions and submit user input with:</p>

<pre><code>&lt;%= form_for(:quiz_responses, url: quiz_responses_path) do |f| %&gt;

&lt;%= f.hidden_field :name, value: @survey.name %&gt;

&lt;% @questions.each do |question| %&gt;
&lt;ul&gt; 
&lt;%= f.hidden_field :question, value: question.content %&gt;
&lt;%= f.label question.content %&gt;

&lt;% question.answers.each do |answer| %&gt;

&lt;%= f.hidden_field :answers, value: answer.content %&gt;

&lt;%= f.label answer.content %&gt;
&lt;%= f.radio_button(:user_answer, answer.content) %&gt;

&lt;% end %&gt;
</code></pre>

<p>There's a few problems with it:</p>

<ol>
<li><p>If I create more than one question, for example 2 questions, I'll get 8 radio buttons, 4 for each question (intended result). However, I can only select one out of the 8 radio boxes (instead of one out of the 4 radio boxes for each question), and only one <code>:user_answer</code> value is submitted. How do I fix this?</p></li>
<li><p>This is most likely related to #1, but <code>&lt;%= f.hidden_field :answers, value: answer.content %&gt;</code> only produces one value when I submit the form (the last answer value). I want it to submit all the answer values (so if I have 2 questions, I'll get a params hash containing 8 answer values instead of 1). A similar problem arises with <code>&lt;%= f.hidden_field :question, value: question.content %&gt;</code></p></li>
</ol>