Try these:
http://railscasts.com/episodes/17
http://railscasts.com/episodes/52
Andrew
On Jul 17, 12:12 pm, quigebo
<quigebo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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
>
> --------
> As you can tell, I am trying to pass a variable name to params. Is
> there a way to do this? Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---