mirror of
https://github.com/github/rails.git
synced 2026-01-30 16:58:15 -05:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user