:controller in :url options?

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.

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

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
validator; and it’s valid:

div
div

Works too!

Stephan