aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb3
-rw-r--r--actionpack/test/dispatch/routing_test.rb6
2 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index fa64a2f1d0..8a84afd315 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -425,10 +425,11 @@ module ActionDispatch
singular
end
+ # Checks for uncountable plurals, and appends "_index" if they're.
def collection_name
uncountable? ? "#{plural}_index" : plural
end
-
+
def uncountable?
singular == plural
end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 4821b5986c..10cc4dfb4f 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -113,7 +113,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
resources :posts, :only => [:index, :show] do
resources :comments, :except => :destroy
end
-
+
resources :sheep
match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
@@ -532,11 +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)
+ assert_equal '/sheep/new', new_sheep_path
+ assert_equal '/sheep/1/edit', edit_sheep_path(1)
end
end