Routing: Slash in front of controller


#1

OK, A while back (pre 1.2, if I remember correctly), putting a slash
in front of a controller name then using link_to would cause any
recalled parameters to be ignored, e.g. On a page with a url of /
articles/edit/1?test=1, the following code would produce a link to /
articles/edit/1:

link_to “Edit”, :controller=>"/articles", :action=>“edit”

This appears to be broken after 1.2, and the following bug report has
been closed with “invalid”:

http://dev.rubyonrails.org/ticket/7792

Does anyone know if this is the new intended functionality, and if so,
is there another way of producing the depreciated effect?

Thanks!


#2

Maybe url_for’s :overwrite_params option will be what you are looking
for. link_to will accept the same options and parameters.

http://api.rubyonrails.org/classes/ActionController/Base.html#M000262

HTH,
Kevin S.
http://www.nullislove.com


#3

Thanks for the reply, Kevin - unfortunately, it’s not what I need, and
the docs do seem to verify that the bug is valid (thanks for the
link). To quote the docs:

There are a few simple rules on how this is performed:

* If the controller name begins with a slash, no defaults are

used: url_for :controller => ‘/home’
* If the controller changes, the action will default to index
unless provided

It seems that the bug report needs to be reopened. Ah well.

Matt