I'm using Rails 2.2.2 with the old school routes (i.e. I'm not being RESTful) and I'm noticing strange behavior coming from the Rails link_to method. Here is my call:
link_to("my description", { :controller => controller, :action => action }, :id => "html_id")
I want the method to produce "/controller/action" but instead I'm getting "/controller/action/id". This only happens when link_to is called while processing a request for a "/controller/action/id" URL, and the controller and action are the same as that which I pass to link_to. Example:
- I'm on the page at "/controller/action" and the links on that page to "/controller/action" are properly pointing to "/controller/action"
- I click a link to "/controller/action/id" and the links on the new page which should point to "/controller/action" now point to "/controller/action/id", where id is the same as the id that was in the previous request.
It seems to me like something is getting confused. There is an id in the request which triggers the link_to call but I don't want it to be referenced and I explicitly don't pass an id parameter. For the record, here are my old school default routes:
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
Any idea why this is happening and, more importantly, how to stop it? Many thanks.