diff options
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index f2e7df6d6d..3771d3fead 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -360,10 +360,12 @@ module ActionController def generate(options, request_or_recall_hash = {}) recall = request_or_recall_hash.is_a?(Hash) ? request_or_recall_hash : request_or_recall_hash.symbolized_path_parameters + use_recall = true controller = options[:controller] recall_controller = recall[:controller] if (recall_controller && recall_controller.include?(?/)) || (controller && controller.include?(?/)) + recall = {} if controller && controller[0] == ?/ options[:controller] = Routing.controller_relative_to(controller, recall_controller) end options = recall.dup if options.empty? # XXX move to url_rewriter? diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index f5149c84bc..55cf5d8e94 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -573,6 +573,9 @@ class RouteSetTests < Test::Unit::TestCase assert_equal ['/admin/user/show', {}], rs.generate({:action => 'show'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) assert_equal ['/admin/user/list/10', {}], rs.generate({}, {:controller => 'admin/user', :action => 'list', :id => '10'}) + + assert_equal ['/admin/stuff', {}], rs.generate({:controller => 'stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) + assert_equal ['/stuff', {}], rs.generate({:controller => '/stuff'}, {:controller => 'admin/user', :action => 'list', :id => '10'}) end def test_ignores_leading_slash |