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 = Question.new @code = ":q_code" + String(count) if( params[:survey][@code] ) @question.question_code = code @question.user_id = @user.id @question.value = params[:survey][@temp] @count += 1 @question.save! else count = false end end