Forum: Ruby on Rails form_remote, getting data from submit

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.
Michiel S. (Guest)
on 2005-12-29 19:11
(Received via mailing list)
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!
J. Ryan S. (Guest)
on 2005-12-29 19:26
(Received via mailing list)
params[:resultset] is what you want.  Try using params[:resultset]
['1'] instead of params[:resultset][1].  (notice the number 1 in quotes)

~ ryan ~
Michiel S. (Guest)
on 2005-12-29 19:42
(Received via mailing list)
2005/12/29, Michiel S. <removed_email_address@domain.invalid>:
> </tr>
>
> 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
This topic is locked and can not be replied to.