This project is archived and is in readonly mode.
Route to root of a namespace
-
josh
- State changed from new to invalid
I didn't realize that worked, but thats not the purpose of "root". The original intent was to provide a convention "root_url" named route plugins, etc could depend on. It doesn't make sense in the nested context.
-
James
Josh,
Previously it provided the "admin_root_url" named route, which seems to me like a great convention as it kept everything (including the index) within the context of admin. Even if you do consider this an "invalid" request, how would you recommend defining the root of a namespace?
James
-
Mark Connell
This does actually work in the new DSL, however you have to explicitly set the namespace in the
:toIn rails 2 if you had an Admin::Posts controller the following would have worked:
# http://localhost:3000/admin map.namespace :admin do |admin| admin.root :controller => 'posts' endAnd the admin.root automagically picked up the namespace context. To do the same in the new routing, the following examples work:
# http://localhost:3000/admin namespace :admin do root :to => "admin/posts#index" end # http://localhost:3000/admin namespace :admin do root :to => "Admin::Posts#index" end -
James
Is there any reason we should need to explicitly set the namespace in the :to when we're within the namespace block? Seems like it should know about the namespace context and avoid duplication.