1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix named route helper for routes nested inside deeply nested resources

[#6416 state:resolved]
This commit is contained in:
Andrew White 2011-02-14 02:56:09 +00:00
parent fd7605826a
commit 460a341682
2 changed files with 10 additions and 2 deletions

View file

@ -1442,7 +1442,7 @@ module ActionDispatch
name = case @scope[:scope_level] name = case @scope[:scope_level]
when :nested when :nested
[member_name, prefix] [name_prefix, prefix]
when :collection when :collection
[prefix, name_prefix, collection_name] [prefix, name_prefix, collection_name]
when :new when :new

View file

@ -187,7 +187,9 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end end
resources :posts, :only => [:index, :show] do resources :posts, :only => [:index, :show] do
resources :comments, :except => :destroy resources :comments, :except => :destroy do
get "views" => "comments#views", :as => :views
end
end end
resource :past, :only => :destroy resource :past, :only => :destroy
@ -2308,6 +2310,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end end
end end
def test_nested_route_in_nested_resource
get "/posts/1/comments/2/views"
assert_equal "comments#views", @response.body
assert_equal "/posts/1/comments/2/views", post_comment_views_path(:post_id => '1', :comment_id => '2')
end
private private
def with_test_routes def with_test_routes
yield yield