# :controller in :url options?

**URL:** <https://www.ruby-forum.com/t/controller-in-url-options/85308>\
**Category:** Rails\
**Created:** [February 12, 2007, 4:21pm UTC](https://www.ruby-forum.com/t/controller-in-url-options/85308 "2007-02-12T16:21:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [February 12, 2007, 4:21pm UTC](https://www.ruby-forum.com/t/controller-in-url-options/85308/1 "2007-02-12T16:21:00Z")

</div>

Hi,

I wish to have a link\_to\_remote tag with a :url to another  
controller.  
Strangely its not working. Am I missing a point here?i.e. is it  
designed  
such?

What I have now is in a view of controller ‘one’:  
\<% link\_to\_remote(“link”, :update =\> ‘div’,  
:url =\> {:controller =\> ‘two’,  
:action =\> ‘x’})

This isn’t working.

Thanks,  
Ram.

---

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [February 12, 2007, 6:13pm UTC](https://www.ruby-forum.com/t/controller-in-url-options/85308/2 "2007-02-12T18:13:35Z")

</div>

Hi Ram,

Ram wrote:

> What I have now is in a view of controller ‘one’:  
> \<% link\_to\_remote(“link”, :update =\> ‘div’,  
> :url =\> {:controller =\> ‘two’,  
> :action =\> ‘x’})
> 
> This isn’t working.

I notice two potential problems.

The first thing I notice is that you’re not rendering the link. That  
is,  
\<% link…  
needs to be  
\<%= link…

The second thing is that you’ve named the DOM element with what I  
believe is  
a reserved word in HTML. (i.e., ‘div’)

If changing these doesn’t produce what you expect, we’ll need more info  
to  
help. The link\_to\_remote method your using does two things and we need  
to  
know which one you’re having problems with.

1. it invokes a method in a controller as specified in your url hash.  
(it  
also allows for passing values from the browser via the params hash)
2. it produces the response the browser will use to update DOM element  
you  
specify in the :update option.

To isolate the problem, in your controller method you should do  
something  
‘extra’ that will leave evidence that the method was triggered. Write a  
record to the database or something like that that you can see.

Also, use Firebug to see the request / response and inspect the DOM.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [February 12, 2007, 6:32pm UTC](https://www.ruby-forum.com/t/controller-in-url-options/85308/3 "2007-02-12T18:32:45Z")

</div>

> The second thing is that you’ve named the DOM element with what I  
> believe is  
> a reserved word in HTML. (i.e., ‘div’)

I put this html, saved as “div.html” through the [http://validator.w3.org](http://validator.w3.org)  
validator; and it’s valid:

 div 
 div 

Works too!

Stephan
