"activos" con el prefijo link_to

I have a link_to in a partial that generates a different URL when the page is accessed as the root then if it is accessed using controller/index. When accessed as the root, the URL the link_to generates has "assets" prefixed to it, which doesn't work.

¿Alguien puede explicar por qué sucede esto?

Rails 3.2.1 Ruby 1.9.3

preguntado el 10 de marzo de 12 a las 15:03

1 Respuestas

With some help from the Rails IRC channel, I found the problem. I was not using the helper paths in the link. In case it will help someone else, here is what I did to fix it;

not working when at the root;

<%= link_to 'Gifts detail', :controller => 'gifts', :action => 'index'%>

working anytime;

<%= link_to 'Gifts detail', gifts_path%>

respondido 10 mar '12, 23:03

I'm having the same problem, but I want to direct the link to a unique controller action. Any idea what I can do? - sybind

Can you set up a route like match ''/contact', :to => 'pages#contact'' then in your link something like '<%= link_to 'Contacts', '/contact'%>' This is just off the top of my head and I am still trying to get my brain around this stuff. - steveo7

I'm using the rails resources in the config/routes.rb file. I dont want to mess with the routing unless I really have to. - sybind

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.