Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7526

Show
Ignore:
Timestamp:
09/21/07 18:06:01 (3 years ago)
Author:
nzkoz
Message:

Prevent clashing named routes when using uncountable resources. Closes #9598

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/resources.rb

    r7447 r7526  
    9797      def action_separator 
    9898        @action_separator ||= Base.resource_action_separator 
     99      end 
     100 
     101      def uncountable? 
     102        @singular.to_s == @plural.to_s 
    99103      end 
    100104 
     
    442446      def map_default_collection_actions(map, resource) 
    443447        index_action_options = action_options_for("index", resource) 
    444         map.named_route("#{resource.name_prefix}#{resource.plural}", resource.path, index_action_options) 
    445         map.named_route("formatted_#{resource.name_prefix}#{resource.plural}", "#{resource.path}.:format", index_action_options) 
     448        index_route_name = "#{resource.name_prefix}#{resource.plural}" 
     449 
     450        if resource.uncountable? 
     451          index_route_name << "_index" 
     452        end 
     453 
     454        map.named_route(index_route_name, resource.path, index_action_options) 
     455        map.named_route("formatted_#{index_route_name}", "#{resource.path}.:format", index_action_options) 
    446456 
    447457        create_action_options = action_options_for("create", resource)