Duane Johnson
2007-May-23 18:40 UTC
Routes namespacing for resources vs. namespacing for regular route--inconsistent?
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"
end
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?
--
Duane Johnson
(canadaduane)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---
Obie Fernandez
2007-Aug-19 18:33 UTC
Re: Routes namespacing for resources vs. namespacing for regular route--inconsistent?
Did anything ever come of this? Cheers, Obie On 5/23/07, Duane Johnson <duane.johnson@gmail.com> wrote:> 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" > end > > 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? > > -- > Duane Johnson > (canadaduane) > > >-- Obie Fernandez http://jroller.com/obie/ Pre-order my book The Rails Way today! http://www.amazon.com/dp/0321445619 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2007-Aug-20 03:34 UTC
Re: Routes namespacing for resources vs. namespacing for regular route--inconsistent?
> Did anything ever come of this?My svn history implies that nothing did. If someone wants to whip up a test case + patch for it we can consider it for inclusion. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---