Hi list, I'm writing a little survey application, and surveys are generated dynamically. I use form_remote_tag and AJAX to submit the form to a method 'submit' in my 'survey' controller. The view generates the form as: <tr> <td>Question 1?</td> <td><input id="resultset_1" name="resultset[1]" size="30" type="text" /></td> </tr> <tr> <td>Question 2?</td> <td><input id="resultset_2" name="resultset[2]" size="30" type="text" /></td> </tr> etc... How can I access the array/object 'resultset' in my submit action in the survey controller? I've tried using @resultset in the 'submit' view or params[:resultset] in the 'submit' action, both seem to be nil. Hope someone can help me. Thanks in advance! -- Michiel Sikkes michiel.sikkes@gmail.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
params[:resultset] is what you want. Try using params[:resultset] [''1''] instead of params[:resultset][1]. (notice the number 1 in quotes) ~ ryan ~ On Dec 29, 2005, at 12:11 PM, Michiel Sikkes wrote:> Hi list, > > I''m writing a little survey application, and surveys are generated > dynamically. I use form_remote_tag and AJAX to submit the form to a > method ''submit'' in my ''survey'' controller. > > The view generates the form as: > <tr> > <td>Question 1?</td> > <td><input id="resultset_1" name="resultset[1]" size="30" > type="text" /></td> > </tr> > <tr> > <td>Question 2?</td> > <td><input id="resultset_2" name="resultset[2]" size="30" > type="text" /></td> > </tr> > etc... > > How can I access the array/object ''resultset'' in my submit action in > the survey controller? I''ve tried using @resultset in the ''submit'' > view or params[:resultset] in the ''submit'' action, both seem to be > nil. > > Hope someone can help me. > > Thanks in advance! > > -- > Michiel Sikkes > michiel.sikkes-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
2005/12/29, Michiel Sikkes <michiel.sikkes@gmail.com>:> Hi list, > > I'm writing a little survey application, and surveys are generated > dynamically. I use form_remote_tag and AJAX to submit the form to a > method 'submit' in my 'survey' controller. > > The view generates the form as: > <tr> > <td>Question 1?</td> > <td><input id="resultset_1" name="resultset[1]" size="30" type="text" /></td> > </tr> > <tr> > <td>Question 2?</td> > <td><input id="resultset_2" name="resultset[2]" size="30" type="text" /></td> > </tr> > etc... > > How can I access the array/object 'resultset' in my submit action in > the survey controller? I've tried using @resultset in the 'submit' > view or params[:resultset] in the 'submit' action, both seem to be > nil. > > Hope someone can help me. > > Thanks in advance!Ah, I think I know what the problem is. I should have some resultset defined in the 'show' method for the view first. But text_field etc. work with @object.method, and not with for example @array[id]. Is there any way of doing the latter thing? TIA -- Michiel Sikkes michiel.sikkes@gmail.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Reasonably Related Threads
- acts_as_versioned
- Keep ketting weird error, NoMethodError in Admin#create_survey Keep getting ''undefined method `assign_variables_from_controller'' for #<Survey:0xb7462244>''
- *Very* basic layout question
- Rails 4: Should a HEAD request not be handled like a GET for CSRF protection?
- Apache proxy + lighttpd + rails