Forum: Ruby on Rails link_to_remote not hitting controller

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Af9a9013100ddf2dbb0ca13487b60f8b?d=identicon&s=25 Ivor Paul (Guest)
on 2007-03-23 12:14
(Received via mailing list)

I have a link_to_remote that should call a function in controller that
updates the page using rjs.

The links are not hitting the controller. I click on the link and
happens in the log file. I suspect it is something small and silly in my

I would appreciate if someone could glance over the code and see if they
spot it - here it is:


    <%= link_to_remote "YES",
          :url => {:controller => 'users',
                   :action => 'toggle_user_roles',
                   :params => {:user_id =>, :role_id =>,
:has_role => true}}%>


<td id='1_1' style="text-align:center;" class="yes_style">
    <a href="#" onclick="new
{asynchronous:true, evalScripts:true}); return false;">YES</a>

The problem is not in the controller as this onClick does not actually
the controller.

thanks in advance
A951364eaa0c5e429515da0c6a2e8383?d=identicon&s=25 askme (Guest)
on 2007-03-23 12:37
(Received via mailing list)
Please check if you included the appropriate public/javascripts(/
prototype) files  in your view ..
Add this line in the view:
 <%= javascript_include_tag :defaults %>

It is a good idea to put this line in the layout file (/app/views/
layout/application.rhtml), so that all the javascripts would be
available in all the views...

-- askme
181035f8aac1cb68d50dc58b67dc0349?d=identicon&s=25 Mischa Berger (mischa78)
on 2007-03-23 12:38
I think it's because of this part in the Ajax.Request: :id.:format

It looks strange and I don't think it should be there. It could have to
do something with routing...?


Af9a9013100ddf2dbb0ca13487b60f8b?d=identicon&s=25 Ivor Paul (Guest)
on 2007-03-23 12:41
(Received via mailing list)
thanks, it was working seconds ago, then I decided I wanted to use a
different layout, made some other minor changes and suddenly it didn't

Thanks for the help!
Af9a9013100ddf2dbb0ca13487b60f8b?d=identicon&s=25 Ivor Paul (Guest)
on 2007-03-23 14:30
(Received via mailing list)
it was because id did not include the js libraries. the :id.:format is
because I am sending 2 params accross, not just the default :id, me
This topic is locked and can not be replied to.