Forum: Ruby on Rails Multiple radio buttons for defining multiple objects?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6494e16518bbdd1a2e06b491d12824ef?d=identicon&s=25 Xavier Lange (Guest)
on 2006-03-10 18:22
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 %>
<p><label for="quesion_1">Question 1</label><br/>
True <%= radio_button('responses', 'response', 'true')%>
False <%= radio_button('responses', 'response', 'false')%>
Maybe <%= radio_button('responses', 'response', 'maybe')%></p>
##################################################

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
This topic is locked and can not be replied to.