Help: Multiple Form Actions


I’m having a hard time finding an answer to my question. I would
like to have multiple form actions based on what the user selects.
For example, I trying to do something similar to Amazon Zuggest,
using Ian McDonald’s Ruby/Amazon.

I have three types of searches which translates to 3 actions in the
SearchController. I have a drop down menu like so,

Music Books DVD

This works. The problem is, I want to use either form_remote_tag or
something like this:

<%= submit_to_remote(“search”, “Search”,
:url => {:controller => “search”, :action =>
:html => {:class => ‘search’},
:update => :item,
:method => ‘get’) %>)

Both of which work perfectly, as the results which I display with a
three different partial templates, are returned without page refresh.

However, in doing so, I am forced to hard code the :action of
submit_to_remote, thereby, disabling the line of javascript in the
select menu.

Does anyone have any ideas on how to implement this ? Sorry that this
is my second time asking this question on this list. I know you’re
all busy, and I know Ruby, but am fairly new to Rails. I’d rather
not use three forms for what should be fairly simple.

Thanks in advance,
Regards, Markus A.


Hello Markus !

2005/11/11, Markus A. removed_email_address@domain.invalid:

<%= submit_to_remote(“search”, “Search”,
:url => {:controller => “search”, :action =>
:html => {:class => ‘search’},
:update => :item,
:method => ‘get’) %>)

You know what I would do ? I would put the target of the action in a
hidden field, and read that hidden field in the submit_to_remote.
Change your :url to:
:url => %Q($(‘id_of_hidden_field’).value)

WARNING: untested - I don’t even know if that’ll work. Worth a try,
don’t you think ?

Bye !