aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/resources.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-09-21 18:06:01 +0000
committerMichael Koziarski <michael@koziarski.com>2007-09-21 18:06:01 +0000
commit045aee89126f87b0519518c9735fe050cb907f23 (patch)
tree59db447f0a59c9ce4845dd2411937e9cf2030e4b /actionpack/lib/action_controller/resources.rb
parenteede82ccb980d9d1c67cddc6972a7125ddab1949 (diff)
downloadrails-045aee89126f87b0519518c9735fe050cb907f23.tar.gz
rails-045aee89126f87b0519518c9735fe050cb907f23.tar.bz2
rails-045aee89126f87b0519518c9735fe050cb907f23.zip
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
Diffstat (limited to 'actionpack/lib/action_controller/resources.rb')
-rw-r--r--actionpack/lib/action_controller/resources.rb14
1 files changed, 12 insertions, 2 deletions
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)