# Link\_to\_remote not hitting controller

**URL:** <https://www.ruby-forum.com/t/link-to-remote-not-hitting-controller/89862>\
**Category:** Rails\
**Created:** [March 23, 2007, 12:14pm UTC](https://www.ruby-forum.com/t/link-to-remote-not-hitting-controller/89862 "2007-03-23T12:14:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![apie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@apie](https://www.ruby-forum.com/u/apie)\
**Post date:** [March 23, 2007, 12:14pm UTC](https://www.ruby-forum.com/t/link-to-remote-not-hitting-controller/89862/1 "2007-03-23T12:14:21Z")

</div>

Hi.

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  
nothing  
happens in the log file. I suspect it is something small and silly in my  
syntax.

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

rhtml:

```
<%= link_to_remote "YES",
      :url => {:controller => 'users',
               :action => 'toggle_user_roles',
               :params => {:user_id => user.id, :role_id => role.id,

```

:has\_role =\> true}}%\>

html:

YES

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

thanks in advance  
ivor

---

<div class="post-metadata">

**Author:** ![apie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@apie](https://www.ruby-forum.com/u/apie)\
**Post date:** [March 23, 2007, 12:37pm UTC](https://www.ruby-forum.com/t/link-to-remote-not-hitting-controller/89862/2 "2007-03-23T12:37:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![apie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@apie](https://www.ruby-forum.com/u/apie)\
**Post date:** [March 23, 2007, 12:38pm UTC](https://www.ruby-forum.com/t/link-to-remote-not-hitting-controller/89862/3 "2007-03-23T12:38:14Z")

</div>

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…?

Mischa.

–  
[http://boxroom.rubyforge.org](http://boxroom.rubyforge.org)

---

<div class="post-metadata">

**Author:** ![apie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@apie](https://www.ruby-forum.com/u/apie)\
**Post date:** [March 23, 2007, 12:41pm UTC](https://www.ruby-forum.com/t/link-to-remote-not-hitting-controller/89862/4 "2007-03-23T12:41:26Z")

</div>

lol!  
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  
work  
🙂

Thanks for the help!  
ivor

---

<div class="post-metadata">

**Author:** ![apie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecccb3/32.png) [@apie](https://www.ruby-forum.com/u/apie)\
**Post date:** [March 23, 2007, 2:30pm UTC](https://www.ruby-forum.com/t/link-to-remote-not-hitting-controller/89862/5 "2007-03-23T14:30:47Z")

</div>

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  
things…
