Topic: link_to to another controller doesn't generate proper link

I'm trying to use link_to to generate links to the index action of another controller and the path that gets generated will only reference the current controller.

Here is the link_to I'm using in my index.html.erb home view:

    <%= link_to 'why', :controller => 'why', :action => 'index', :id => "what-selectedtab", :class => "what-alltabs" do %>
            <h3>How will this help?</h3>
        <% end %>

and here is the URL that gets generated to the why view:

http://localhost:3000/home/why

I want this instead to go to

http://localhost:3000/why/index

Thanks

Last edited by davidsaki (2012-12-17 00:02:44)

Re: link_to to another controller doesn't generate proper link

It shouldn't.

Here is an example from the docs:
<code>
link_to "Profile", :controller => "profiles", :action => "show", :id => @profile
# => <a href="/profiles/show/1">Profile</a>
</code>

Can you post the results of your rake routes? Maybe your routes file too?

Last edited by tuscanidream (2012-12-17 11:47:01)

Learning rails, one day at a time.

http://keilmiller.com