# Plz hlp :-( Link is not directing to function in controller

**URL:** <https://www.ruby-forum.com/t/plz-hlp-link-is-not-directing-to-function-in-controller/172176>\
**Category:** Rails\
**Created:** [July 16, 2009, 8:38am UTC](https://www.ruby-forum.com/t/plz-hlp-link-is-not-directing-to-function-in-controller/172176 "2009-07-16T08:38:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkat\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/4af34b/32.png) [@venkat\_ruby](https://www.ruby-forum.com/u/venkat_ruby)\
**Post date:** [July 16, 2009, 8:38am UTC](https://www.ruby-forum.com/t/plz-hlp-link-is-not-directing-to-function-in-controller/172176/1 "2009-07-16T08:38:55Z")

</div>

Hi all,

The below link is not directing to media\_files\_list function but  
directing to the show function. Please help, i want to direct it to  
media\_files\_list function.  
In controller i declared…  
def media\_files\_list

Please note: i want to use get-method as below.

\<a onclick=“new Ajax.Request(’/media\_files/media\_files\_list’,  
{asynchronous:true, evalScripts:true, method:‘get’,  
onSuccess:function(request){handleData(request,“centernav”)},  
parameters:‘module\_id=MENU09041512&upload\_list=true&page=2’ +  
‘&authenticity\_token=’ +  
encodeURIComponent(‘s5Tjz5cJJl28uR0OGMbALzbh8ktwLkL2+fVjPBruqmk=’)});  
return false;” href="#"\>2

---

<div class="post-metadata">

**Author:** ![venkat\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/4af34b/32.png) [@venkat\_ruby](https://www.ruby-forum.com/u/venkat_ruby)\
**Post date:** [July 16, 2009, 8:49am UTC](https://www.ruby-forum.com/t/plz-hlp-link-is-not-directing-to-function-in-controller/172176/2 "2009-07-16T08:49:04Z")

</div>

Provide the actual line of code

---

<div class="post-metadata">

**Author:** ![venkat\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/4af34b/32.png) [@venkat\_ruby](https://www.ruby-forum.com/u/venkat_ruby)\
**Post date:** [July 16, 2009, 8:52am UTC](https://www.ruby-forum.com/t/plz-hlp-link-is-not-directing-to-function-in-controller/172176/3 "2009-07-16T08:52:56Z")

</div>

Rails L. wrote:

> Provide the actual line of code

\<%= link\_to\_remote page\_no,  
:success =\>‘handleData(request,“centernav”)’,  
:url =\> {  
:action =\> params[:action],  
:controller =\>params[:controller]  
},  
:with =\>  
“‘module\_id=#{module\_id}&upload\_list=true&page=#{page\_no}’”,  
:method =\> :get  
%\>  
\<% end %\>

---

<div class="post-metadata">

**Author:** ![venkat\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/4af34b/32.png) [@venkat\_ruby](https://www.ruby-forum.com/u/venkat_ruby)\
**Post date:** [July 16, 2009, 11:55am UTC](https://www.ruby-forum.com/t/plz-hlp-link-is-not-directing-to-function-in-controller/172176/4 "2009-07-16T11:55:31Z")

</div>

Venkat E. wrote:

> Rails L. wrote:
> 
> > Provide the actual line of code
> 
> \<%= link\_to\_remote page\_no,  
> :success =\>‘handleData(request,“centernav”)’,  
> :url =\> {  
> :action =\> params[:action],  
> :controller =\>params[:controller]  
> },  
> :with =\>  
> “‘module\_id=#{module\_id}&upload\_list=true&page=#{page\_no}’”,  
> :method =\> :get  
> %\>  
> \<% end %\>

dude  
i think you have written this code in your show.html.erb and because of  
that params[:action] is going to return “show” that why your request  
is going to show action instead of  
def media\_files\_list

used something like this

\<%= link\_to\_remote page\_no,  
:success =\>‘handleData(request,“centernav”)’,  
:url =\> media\_files\_list\_[“your controller name”]\_path(parameter)  
:with =\>  
“‘module\_id=#{module\_id}&upload\_list=true&page=#{page\_no}’”,  
:method =\> :get  
%\>  
\<% end %\>

this should work  
do rake routes for more information  
controller name can be singular or plural based on the definition of  
your methods defined in your route.rb
