This project is archived and is in readonly mode.
router scope does not behave as documented
Reported by Rob Greenwood | July 5th, 2010 @ 01:12 PM | in 3.0.2
The router documentation (http://guides.rails.info/routing.html#prefixing-the-named-route-hel...) states the following:
To prefix a group of routes, use :as with scope:
scope "admin", :as => "admin" do
resources :photos, :accounts
end
However, when putting this code into config/routes.rb and executing rake:routes, the following is shown:
~/Code/wombat[master]% rake routes
(in /home/rob/Code/wombat)
GET /admin/photos(.:format) {:controller=>"photos", :action=>"index"}
POST /admin/photos(.:format) {:controller=>"photos", :action=>"create"}
GET /admin/photos/new(.:format) {:controller=>"photos", :action=>"new"}
GET /admin/photos/:id(.:format) {:controller=>"photos", :action=>"show"}
PUT /admin/photos/:id(.:format) {:controller=>"photos", :action=>"update"}
DELETE /admin/photos/:id(.:format) {:controller=>"photos", :action=>"destroy"}
GET /admin/photos/:id/edit(.:format) {:controller=>"photos", :action=>"edit"}
GET /admin/accounts(.:format) {:controller=>"accounts", :action=>"index"}
admins POST /admin/accounts(.:format) {:controller=>"accounts", :action=>"create"}
new_admin GET /admin/accounts/new(.:format) {:controller=>"accounts", :action=>"new"}
GET /admin/accounts/:id(.:format) {:controller=>"accounts", :action=>"show"}
PUT /admin/accounts/:id(.:format) {:controller=>"accounts", :action=>"update"}
admin DELETE /admin/accounts/:id(.:format) {:controller=>"accounts", :action=>"destroy"}
edit_admin GET /admin/accounts/:id/edit(.:format) {:controller=>"accounts", :action=>"edit"}
~/Code/wombat[master]%
Instead of appending a path prefix, so for example edit_admin_account etc, it appears to be completely messing up the path names.
Comments and changes to this ticket
-
José Valim July 5th, 2010 @ 02:18 PM
- Assigned user set to José Valim
- State changed from new to invalid
- Milestone cleared.
- Importance changed from to Low
I'm using Rails master and it works as expected (and documented). You are probably using the old version where :as was called :name_prefix.
-
Rob Greenwood July 5th, 2010 @ 02:31 PM
Yep, you're right. Obviously this change must have happened after beta4.
Wombat::Application.routes.draw do |map| # Admin Routes scope :module => "admin", :name_prefix => "admin", :constraints => { :subdomain => "admin" } do root :to => 'dashboard#welcome' end end
Works fine
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>