This project is archived and is in readonly mode.
Redirect broken when using namespaces in routes.rb
Reported by wildchild | April 14th, 2010 @ 03:14 AM
In order to be redirected to /admin/dashboard from /admin I defined the following routes:
namespace :admin do
match "/", :to => redirect("/admin/dashboard")
match "/dashboard", :to => "dashboard#index", :as => :dashboard
end
It results in: "ActionController::RoutingError (uninitialized constant Admin::Controller):"
Different one works as expected:
match "/admin", :to => redirect("/admin/dashboard")
namespace :admin do
match "/dashboard", :to => "dashboard#index", :as => :dashboard
end
But I can't relax, it seems something wrong in the router internals, right?
Comments and changes to this ticket
-
Tyler Hunt June 22nd, 2010 @ 04:19 PM
This also fails with the same error when using #root:
namespace :admin do root :to => redirect('/admin/companies') resources :companies end
-
Andrew White June 24th, 2010 @ 10:55 AM
Attached patch fixes this issue.
I've written it so that the redirect path is namespaced which seems logical to me:
namespace :admin do root :to => redirect('/companies') resources :companies end
If you don't want it this way then let me know and I'll change the patch.
-
Damien MATHIEU June 24th, 2010 @ 11:06 AM
If the redirect path is namespaced, it mean we can't redirect to a path outside of the current namespace. That doesn't seem so logical to me.
-
Andrew White June 24th, 2010 @ 11:16 AM
I thought about that and you'd handle that situation like this:
match '/admin', :to => redirect('/other')
To me it seems everything within a namespace block should be namespaced.
-
Andrew White June 24th, 2010 @ 11:51 AM
- State changed from new to open
Updated patch which doesn't namespace redirect path
-
Repository June 24th, 2010 @ 12:28 PM
- State changed from open to resolved
(from [df15ba7eadb180626474161741f901e675f517ce]) Fix namespaced redirects [#4389 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/df15ba7eadb180626474161741f901...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 4389 Redirect broken when using namespaces in routes.rb (from [df15ba7eadb180626474161741f901e675f517ce]) Fix nam...