mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add _index to named collection routes for uncountable resources (e.g. Sheep)
Signed-off-by: Rizwan Reza <rizwanreza@gmail.com>
This commit is contained in:
parent
4b07352420
commit
72074aac33
2 changed files with 14 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue