# Link\_to only links to current controller?

**URL:** <https://www.ruby-forum.com/t/link-to-only-links-to-current-controller/134099>\
**Category:** Rails\
**Created:** [April 7, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/link-to-only-links-to-current-controller/134099 "2008-04-07T21:42:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenatron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@glenatron](https://www.ruby-forum.com/u/glenatron)\
**Post date:** [April 7, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/link-to-only-links-to-current-controller/134099/1 "2008-04-07T21:42:44Z")

</div>

This is really confusing to me- I have some code in a page on the site  
I’m working on that works absolutely fine on one version of the code and  
totally doesn’t work on a newer version, in spite of the fact I can see  
no difference whatsoever either in the rhtml pages, the controller or  
any of the routing code. Right now I literally have no idea what the  
cause of this could be.

This code lists FAQ entries (in faq\_controller.rb ):

\<% @questionList.each do |question| %\>- \<%=link\_to(question.question, :action=\>'show\_question', :id=\>question.id)%\>
\<% end %\>

On the current code it gives this output:

- [What is question 1?](https://www.ruby-forum.com/faq/show_question/1)

When I switch to the new codebase I get this:

- [What is question 1?](https://www.ruby-forum.com/faq)

Every single link I generate with link\_to() is having it’s path replaced  
by a link to “/faq” both in the current partial and in the layout.

I added some testing code to see what url\_for is returning-  
\<%  
logger.info “Test 1:”+url\_for( :controller=\>‘faq’,  
:action=\>‘show\_question’, :id=\>11 )  
logger.info "Test 2: "removed\_email\_address@domain.invalid(:url\_for,  
{:action=\>‘show\_question’, :id=\>1})  
%\>  
The former gives /faq the latter gives /faq/show\_question/1 but it  
doesn’t seem normal to have to keep calling @controller.send to get my  
links working.

The other problem I have is that on my staging server and my local  
machine I don’t have this problem- it only arises on the live deployment  
server when it is running in production mode, which means I can only  
test it for seconds at the time if I don’t want to start seriously  
interfering with our users’ experience.

Any guesses as to what might be causing this? It’s driving me up the  
wall.
