Forum: Ruby on Rails How do I collect values from X number of radio buttons?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7c30ed889b33225ab0ffb0df49ff5f9d?d=identicon&s=25 quigebo (Guest)
on 2007-07-17 05:31
(Received via mailing list)
I am currently writing an application to collect data from a survey
form. I would like to write it so that it saves all of the information
from various radio buttons into the database. Obviously, I could hard-
code each individual radio button to be collected but I want to create
a loop that automatically does this in case new questions are added.
Here is some sample code I tried to use (but failed, obviously)

while( count )
    @question =
    @code = ":q_code" + String(count)
    if( params[:survey][@code] )
      @question.question_code = code
      @question.user_id =
    @question.value = params[:survey][@temp]
      @count += 1!
    count = false

As you can tell, I am trying to pass a variable name to params. Is
there a way to do this? Thanks!
3e6bbd5a01437feec48adf3838b15d91?d=identicon&s=25 askegg (Guest)
on 2007-07-18 03:09
(Received via mailing list)
This topic is locked and can not be replied to.