Thank you very much Pascal, it was really useful for me. I noticed a similar behavior when setting up my nested resources.
I would add something, an option to use the block operator for small instead of parameter. Right now, using the syntax you specified, only direct descendants (: pages) will be shallow.
If you want to nest one level deeper (let it skip the argument about whether these are best practices or not), using a shallow block will be as insignificant as necessary:
resources :users do shallow do resources :categories do resources :sections do resources :pages end end resources :news end end
Here is an example of what available route helpers you will have for all resources nested inside: users
new_category_section GET (/:locale)(/:locale)/categorys/:category_id/sections/new(.:format) {:locale=>/fr|en/, :action=>"new", :controller=>"sections"} edit_section GET (/:locale)(/:locale)/sections/:id/edit(.:format) {:locale=>/fr|en/, :action=>"edit", :controller=>"sections"} section GET (/:locale)(/:locale)/sections/:id(.:format) {:locale=>/fr|en/, :action=>"show", :controller=>"sections"} PUT (/:locale)(/:locale)/sections/:id(.:format) {:locale=>/fr|en/, :action=>"update", :controller=>"sections"} DELETE (/:locale)(/:locale)/sections/:id(.:format) {:locale=>/fr|en/, :action=>"destroy", :controller=>"sections"} section_pages GET (/:locale)(/:locale)/sections/:section_id/pages(.:format) {:locale=>/fr|en/, :action=>"index", :controller=>"pages"} POST (/:locale)(/:locale)/sections/:section_id/pages(.:format) {:locale=>/fr|en/, :action=>"create", :controller=>"pages"} new_section_info_page GET (/:locale)(/:locale)/sections/:section_id/pages/new(.:format) {:locale=>/fr|en/, :action=>"new", :controller=>"pages"} dit_info_page GET (/:locale)(/:locale)/pages/:id/edit(.:format) {:locale=>/fr|en/, :action=>"edit", :controller=>"pages"} info_page GET (/:locale)(/:locale)/pages/:id(.:format) {:locale=>/fr|en/, :action=>"show", :controller=>"pages"} PUT (/:locale)(/:locale)/pages/:id(.:format) {:locale=>/fr|en/, :action=>"update", :controller=>"pages"} DELETE (/:locale)(/:locale)/pages/:id(.:format) {:locale=>/fr|en/, :action=>"destroy", :controller=>"pages"}
Olivier lacan
source share