Multiple radio buttons for defining multiple objects?


#1

Hi, I’ve been working on a multiple choice Question/Answer system. The
response object (analagous to a lineitem) has a question_id, user_id,
and the actual response. What’s a good way of making a form with
multiple response objects which are created from the radio_button
helper?

Right now I’ve got the following code:

##################################################
<%= start_form_tag :action => ‘dump’, :id => @user.id %>

Question 1
True <%= radio_button('responses', 'response', 'true')%> False <%= radio_button('responses', 'response', 'false')%> Maybe <%= radio_button('responses', 'response', 'maybe')%>

##################################################

I’m just using dump to show the params, which puts out
{“responses”=>{“response”=>“true”}, “commit”=>“Take the test”,
“action”=>“dump”, “id”=>“8”, “controller”=>“survey”}. How do I add a
question_id, user_id straight into that “responses” hash?

Also, how should I create multiple response objects later? I’m very
shakey on how to create multiple instances of the same object from one
form…

Thanks,
Xavier