I've recently filed an enhancement request to allow drawing nested
route urls that are more user and search engine friendly. The ticket
is here:
http://rails.lighthouseapp.com/projects/8994/tickets/436-implied-routes-to-nested-collections
I'm seeking feedback. There's a plugin to enable easy experimentation,
and a patch to rails, both hosted on github and linked from the
ticket.
This patch really works best when using "pretty urls" and results in a
url like so:
/local/categories/restaurants/subcategories/korean/states/california/
cities/mountain-view/businesses/totoro-tofu-house
to become:
/local/restaurants/korean/california/mountain-view/totoro-tofu-house
By changing your routes from this:
map.namespace :local do |local|
local.resources :categories do |categories|
categories.resources :subcategories do |subcategories|
subcategories.resources :states do |states|
states.resources :cities do |cities|
cities.resources :businesses
end
end
end
end
end
to this:
map.namespace :local do |local|
local.resources :categories, :default => true, :show
=> :subcategories do |categories|
categories.resources :subcategories, :show => :states do |
subcategories|
subcategories.resources :states, :show => :cities do |states|
states.resources :cities, :show => :businesses do |cities|
cities.resources :businesses
end
end
end
end
end
Clearly this approach results in a routing collision of the show
action and the index action and you can control which one will get
precedence in the routing table by using :show or :default. In all
cases, both routes gets written so that the named routes work as
expected, even though they both are recognized as the same.
Thanks,
Chris
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---