diff options
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 2546bdd43e..fa64a2f1d0 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -426,7 +426,11 @@ module ActionDispatch end def collection_name - plural + uncountable? ? "#{plural}_index" : plural + end + + def uncountable? + singular == plural end def name_for_action(action) diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index b1de96cee5..4821b5986c 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -113,6 +113,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest resources :posts, :only => [:index, :show] do resources :comments, :except => :destroy end + + resources :sheep match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp @@ -530,6 +532,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest 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 |