aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb15
-rw-r--r--actionpack/test/dispatch/routing_test.rb8
2 files changed, 12 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 8dfac30ac0..34d75e55b6 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -80,15 +80,19 @@ module ActionDispatch
resource = SingletonResource.new(resources.pop, :name_prefix => name_prefix)
if @scope[:scope_level] == :resources
- member do
- resource(resource.name, options, &block)
+ parent_resource = @scope[:scope_level_options][:name]
+ parent_named_prefix = @scope[:scope_level_options][:name_prefix]
+ with_scope_level(:member) do
+ scope(":#{parent_resource}_id", :name_prefix => parent_named_prefix) do
+ resource(resource.name, options, &block)
+ end
end
return self
end
controller(resource.controller) do
namespace(resource.name) do
- with_scope_level(:resource, :name => resource.singular) do
+ with_scope_level(:resource, :name => resource.singular, :name_prefix => resource.member_name) do
yield if block_given?
get "", :to => :show, :as => resource.member_name
@@ -118,8 +122,9 @@ module ActionDispatch
if @scope[:scope_level] == :resources
parent_resource = @scope[:scope_level_options][:name]
+ parent_named_prefix = @scope[:scope_level_options][:name_prefix]
with_scope_level(:member) do
- scope(":#{parent_resource}_id", :name_prefix => parent_resource) do
+ scope(":#{parent_resource}_id", :name_prefix => parent_named_prefix) do
resources(resource.name, options, &block)
end
end
@@ -128,7 +133,7 @@ module ActionDispatch
controller(resource.controller) do
namespace(resource.name) do
- with_scope_level(:resources, :name => resource.singular) do
+ with_scope_level(:resources, :name => resource.singular, :name_prefix => resource.member_name) do
yield if block_given?
collection do
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 496445fc34..b8bcdc2808 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -251,9 +251,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get '/projects/1/companies/1/people'
assert_equal 'people#index', @response.body
- pending do
- assert_equal '/projects/1/companies/1/people', project_company_people_path(:project_id => '1', :company_id => '1')
- end
+ assert_equal '/projects/1/companies/1/people', project_company_people_path(:project_id => '1', :company_id => '1')
get '/projects/1/companies/1/avatar'
assert_equal 'avatars#show', @response.body
@@ -345,9 +343,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get '/projects/1/posts/1/comments'
assert_equal 'comments#index', @response.body
- pending do
- assert_equal '/projects/1/posts/1/comments', project_post_comments_path(:project_id => '1', :post_id => '1')
- end
+ assert_equal '/projects/1/posts/1/comments', project_post_comments_path(:project_id => '1', :post_id => '1')
post '/projects/1/posts/1/comments/preview'
assert_equal 'comments#preview', @response.body