From 045aee89126f87b0519518c9735fe050cb907f23 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Fri, 21 Sep 2007 18:06:01 +0000 Subject: Prevent clashing named routes when using uncountable resources. Closes #9598 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7526 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/resources.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 7b311e5eb7..898425bbee 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -98,6 +98,10 @@ module ActionController @action_separator ||= Base.resource_action_separator end + def uncountable? + @singular.to_s == @plural.to_s + end + protected def arrange_actions @collection_methods = arrange_actions_by_methods(options.delete(:collection)) @@ -441,8 +445,14 @@ module ActionController def map_default_collection_actions(map, resource) index_action_options = action_options_for("index", resource) - map.named_route("#{resource.name_prefix}#{resource.plural}", resource.path, index_action_options) - map.named_route("formatted_#{resource.name_prefix}#{resource.plural}", "#{resource.path}.:format", index_action_options) + index_route_name = "#{resource.name_prefix}#{resource.plural}" + + if resource.uncountable? + index_route_name << "_index" + end + + map.named_route(index_route_name, resource.path, index_action_options) + map.named_route("formatted_#{index_route_name}", "#{resource.path}.:format", index_action_options) create_action_options = action_options_for("create", resource) map.connect(resource.path, create_action_options) -- cgit v1.2.3