Skip to content

Commit

Permalink
Fix named route helper for routes nested inside deeply nested resources
Browse files Browse the repository at this point in the history
[#6416 state:resolved]
  • Loading branch information
pixeltrix committed Feb 14, 2011
1 parent fd76058 commit 460a341
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -1442,7 +1442,7 @@ def name_for_action(as, action) #:nodoc:

name = case @scope[:scope_level]
when :nested
[member_name, prefix]
[name_prefix, prefix]
when :collection
[prefix, name_prefix, collection_name]
when :new
Expand Down
10 changes: 9 additions & 1 deletion actionpack/test/dispatch/routing_test.rb
Expand Up @@ -187,7 +187,9 @@ def self.call(params, 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
Expand Down Expand Up @@ -2308,6 +2310,12 @@ def test_controller_name_with_leading_slash_raise_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
Expand Down

0 comments on commit 460a341

Please sign in to comment.