From 314273d0ed43cfacb213e036f1645e95dc123b8a Mon Sep 17 00:00:00 2001 From: Jan De Poorter Date: Fri, 12 Feb 2010 11:39:19 +0100 Subject: [PATCH] Make sure nested singular resources get the correct name --- actionpack/lib/action_dispatch/routing/mapper.rb | 5 ++++- actionpack/test/dispatch/routing_test.rb | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 8de68b3..eb77577 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -451,7 +451,10 @@ module ActionDispatch scope(:path => resource.name.to_s, :controller => resource.controller) do with_scope_level(:resource, resource) do - yield if block_given? + + scope(:name_prefix => resource.name.to_s) do + yield if block_given? + end get :show if resource.actions.include?(:show) post :create if resource.actions.include?(:create) diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index bcb97e4..78ed12a 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -24,6 +24,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest resource :session do get :create + + resource :info end match 'account/logout' => redirect("/logout"), :as => :logout_redirect @@ -229,6 +231,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '/session/edit', edit_session_path end end + + def test_session_info_nested_singleton_resource + with_test_routes do + get '/session/info' + assert_equal 'infos#show', @response.body + assert_equal '/session/info', session_info_path + end + end def test_redirect_modulo with_test_routes do -- 1.6.5.7