# Multiple :url in remote\_form\_for

**URL:** <https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694>\
**Category:** Rails\
**Created:** [January 1, 2008, 6:08am UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694 "2008-01-01T06:08:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [January 1, 2008, 6:08am UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694/1 "2008-01-01T06:08:11Z")

</div>

Hi. I’m developing a Ruby Application. I would like to perform several  
actions, that is, call more than one action in 1 controller when  
someone clicks the submit\_tag using ajax, rjs, etc.  
Right now it is working perfectly but with just one call.  
This is how the code looks like:  
\<% form\_remote\_for :tag,  
:loading =\> visual\_effect(:appear, :loading\_div),  
:success =\> visual\_effect(:fade, :loading\_div),  
:failure =\> “alert('HTTP Error ’ + request.status +  
‘!’)”, #visual\_effect(:fade, :loading\_div),  
:url =\> {:controller =\> “build”, :action =\> “parse”} do |  
f| %\>

```
      Search: <%= f.text_field :title %>

                  <%= submit_tag "Submit" %>

```

\<% end %\>

So the idea is to have two  
:url =\> {:controller =\> “build”, :action =\> “parse”}  
:url =\> {:controller =\> “build”, :action =\> “parse2”}  
and when someone clicks the button to run both of them concurrently.  
Is this possible in any way?  
Thanks in advance 😉  
Happy 2008 😉

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [January 1, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694/2 "2008-01-01T17:35:50Z")

</div>

Javier Q. wrote:

> ```
> :url => {:controller => "build", :action => "parse"} do |
> 
> ```
> 
> :url =\> {:controller =\> “build”, :action =\> “parse”}  
> :url =\> {:controller =\> “build”, :action =\> “parse2”}  
> and when someone clicks the button to run both of them concurrently.  
> Is this possible in any way?

Yes, add option

:html =\> {:onsubmit =\> remote\_function(:url =\> {:controller =\> ‘build’,  
:action =\> :parse2})}

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [January 1, 2008, 11:34pm UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694/3 "2008-01-01T23:34:57Z")

</div>

what if I want to have 3 or 4? or 100?  
Thanks for your reply!

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [January 1, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694/4 "2008-01-01T23:40:13Z")

</div>

Having multiple is just stupid. If you want it to do multiple things at  
the  
same time, stick them all in the same action and only call one URL.

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [January 2, 2008, 1:01am UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694/5 "2008-01-02T01:01:30Z")

</div>

You can render as many partials as you want, concurrently.

For example:  
\<%= render :partial =\> “number\_1” %\>  
\<%= render :partial =\> “number\_2” %\>

If you’re using render :update in your action do a  
page.replace\_html :element\_on\_the\_page, :partial =\> “number\_1”  
page.replace\_html :other\_element\_on\_the\_page, :partial =\> “number\_2”

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [January 1, 2008, 11:49pm UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694/6 "2008-01-01T23:49:35Z")

</div>

Not really Ryan. There is at least one case in which is interesting to  
do. Since you can’t have more than one render per action and there are  
times when you want to render partials concurrently.  
So, is there any way to do it? I was trying another solution by  
creating Threads in the controller but i think that it will be easier  
this way.  
Check  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/e11f83680ee71eef](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/e11f83680ee71eef)  
to see what happens if you try to do it with multiple threads and  
multiple renders.

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [January 2, 2008, 1:56pm UTC](https://www.ruby-forum.com/t/multiple-url-in-remote-form-for/124694/7 "2008-01-02T13:56:41Z")

</div>

Javier Q. wrote:

> what if I want to have 3 or 4? or 100?

You can create a JavaScript function that is called by  
the onsubmit event, and which calls remote\_function in  
a loop.

Concurrency will however be limited by both the number of  
simultaneous connections for a browser and the number  
of Rails handlers you are running.

However this method does allow multiple changes to be  
sent to the browser concurrently, in contrast to  
the Thread option (in your other post), which only sends  
to the browser when all threads have completed.

–  
We develop, watch us RoR, in numbers too big to ignore.
