+1 to the current behaviour... it's just like accessing a relative file path vs an absolute one.
Cheers. On Sep 23, 8:13 am, "Michael Koziarski" <[EMAIL PROTECTED]> wrote: > On Sun, Sep 21, 2008 at 9:03 AM, Andrew Kaspick <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I've run across an issue with namespaced controllers and url generation. > > > Fromhttp://github.com/rails/rails/tree/master/actionpack/lib/action_contr... > > (line 322) I'm wondering what the purpose of the section of code with > > this comment is: > > > # if the controller has changed, make sure it changes relative to the > > # current controller module, if any. In other words, if we're currently > > # on admin/get, and the new controller is 'set', the new controller > > # should really be admin/set. > > > My scenario is the following... > > > I have view layout code with link_to's the use a hash to specify the url > > > link_to 'Example', {:controller => 'nonamespace', :action => 'index'} > > > which generates "/nonamespace" > > > But when I access a controller that is namespaced such as > > "/namespace/blah/action", that same link_to now generates > > "/namespace/nonamespace" > > > So from what I can tell the routing code is making an assumption that > > I don't think it should which seems to be that generated urls > > (sepcified with a hash) should remain in the context of the current > > views controller. In my case it's code for a layout which can apply > > to many controllers, so this assumption is incorrect and causing this > > issue. > > > Can somebody explain the assumption made by the routing code and if > > this is indeed a bug? > > Whether it's a bug or not is kind of a matter of interpretation. But > the *original intention* here was to support nested controllers with > relative links. So, f.ex: > > Admin > - UsersController > - TagsController > UsersController > > If you're in admin/tags/somethign and link to :controller=>'users'. > Where is it meant to go? With the current behaviour it will go to > /admin/users which is 'probably' a reasonable assumption. > > You can work around this with :controller=> '/nonamespace' which will > work from anywhere. > > I'm interested in people's opinions on this one, we can't really > change it for 2.2, but for the 2.3.x series we could try and > rationalise all this stuff. > > -- > Cheers > > Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
