For your consideration, two snippets from a routes.rb file:
map.namespace(:bookshelf, :path_prefix => “/bookshelf/:book_id”) do |bookshelf| bookshelf.resources :sections bookshelf.resources :templates end
map.namespace(:bookshelf) do |bookshelf| bookshelf.publish “:book_id/publish”, :controller => “publish” bookshelf.physical_pages “:book_id/physical_pages”, :controller => “physical_pages”
Both of these “namespace” blocks create routes to paths such as: “/bookshelf/1/sections” “/bookshelf/1/publish”
I was unable to use :path_prefix in the second map.namespace case, as it would then (apparently) try to route the “:controller” segment to “bookshelf/:book_id/publish”. Obviously, no such controller exists.
It seems to me that the “resources” method is smart enough to use the path_prefix for constructing the path only, while the regular named routes try to prepend the path_prefix directly to the name of the controller.
It would be nice to remove the redundancy and combine these two map.namespace blocks in to one. Am I missing something, or can anyone confirm this assessment?