Skip to content
This repository
Browse code

Fix named route helper for routes nested inside deeply nested resources

[#6416 state:resolved]
  • Loading branch information...
commit 64ca278176cee08ec0c368be113726ed93d41288 1 parent b4205b4
Andrew White authored February 14, 2011
2  actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1331,7 +1331,7 @@ def name_for_action(as, action)
1331 1331
 
1332 1332
             name = case @scope[:scope_level]
1333 1333
             when :nested
1334  
-              [member_name, prefix]
  1334
+              [name_prefix, prefix]
1335 1335
             when :collection
1336 1336
               [prefix, name_prefix, collection_name]
1337 1337
             when :new
10  actionpack/test/dispatch/routing_test.rb
@@ -171,7 +171,9 @@ def self.matches?(request)
171 171
       end
172 172
 
173 173
       resources :posts, :only => [:index, :show] do
174  
-        resources :comments, :except => :destroy
  174
+        resources :comments, :except => :destroy do
  175
+          get "views" => "comments#views", :as => :views
  176
+        end
175 177
       end
176 178
 
177 179
       resource  :past, :only => :destroy
@@ -2229,6 +2231,12 @@ def test_multiline_routing_constraint_raises_error
2229 2231
     end
2230 2232
   end
2231 2233
 
  2234
+  def test_nested_route_in_nested_resource
  2235
+    get "/posts/1/comments/2/views"
  2236
+    assert_equal "comments#views", @response.body
  2237
+    assert_equal "/posts/1/comments/2/views", post_comment_views_path(:post_id => '1', :comment_id => '2')
  2238
+  end
  2239
+
2232 2240
 private
2233 2241
   def with_test_routes
2234 2242
     yield

0 notes on commit 64ca278

Please sign in to comment.
Something went wrong with that request. Please try again.