Permalink
Browse files

Add _index to named collection routes for uncountable resources (e.g.…

… Sheep)

Signed-off-by: Rizwan Reza <rizwanreza@gmail.com>
  • Loading branch information...
DefV authored and wycats committed Feb 25, 2010
1 parent 4b07352 commit 72074aac334a846fbb53e7cb12c0254c15004c26
Showing with 14 additions and 1 deletion.
  1. +5 −1 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +9 −0 actionpack/test/dispatch/routing_test.rb
@@ -426,7 +426,11 @@ def member_name
end
def collection_name
- plural
+ uncountable? ? "#{plural}_index" : plural
+ end
+
+ def uncountable?
+ singular == plural
end
def name_for_action(action)
@@ -113,6 +113,8 @@ def self.matches?(request)
resources :posts, :only => [:index, :show] do
resources :comments, :except => :destroy
end
+
+ resources :sheep
match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
@@ -530,6 +532,13 @@ def test_resource_routes_with_only_and_except
assert_raise(ActionController::RoutingError) { delete '/posts/1/comments' }
end
end
+
+ def test_resources_for_uncountable_names
+ with_test_routes do
+ assert_equal '/sheep', sheep_index_path
+ assert_equal '/sheep/1', sheep_path(1)
+ end
+ end
def test_path_names
with_test_routes do

0 comments on commit 72074aa

Please sign in to comment.