Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix named route helper for routes nested inside deeply nested resources

[#6416 state:resolved]
  • Loading branch information...
commit 64ca278176cee08ec0c368be113726ed93d41288 1 parent b4205b4
Andrew White pixeltrix authored
2  actionpack/lib/action_dispatch/routing/mapper.rb
View
@@ -1331,7 +1331,7 @@ def name_for_action(as, action)
name = case @scope[:scope_level]
when :nested
- [member_name, prefix]
+ [name_prefix, prefix]
when :collection
[prefix, name_prefix, collection_name]
when :new
10 actionpack/test/dispatch/routing_test.rb
View
@@ -171,7 +171,9 @@ def self.matches?(request)
end
resources :posts, :only => [:index, :show] do
- resources :comments, :except => :destroy
+ resources :comments, :except => :destroy do
+ get "views" => "comments#views", :as => :views
+ end
end
resource :past, :only => :destroy
@@ -2229,6 +2231,12 @@ def test_multiline_routing_constraint_raises_error
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
def with_test_routes
yield
Please sign in to comment.
Something went wrong with that request. Please try again.