diff options
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 7e71a6057b..27f651da51 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -360,8 +360,10 @@ 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 - if ((rc_c = recall[:controller]) && rc_c.include?(?/)) || ((c = options[:controller]) && c.include?(?/)) - options[:controller] = Routing.controller_relative_to(c, rc_c) + controller = options[:controller] + recall_controller = recall[:controller] + if (recall_controller && recall_controller.include?(?/)) || (controller && controller.include?(?/)) + options[:controller] = Routing.controller_relative_to(controller, recall_controller) end options = recall.dup if options.empty? # XXX move to url_rewriter? Routing.treat_hash(options) # XXX Move inwards (to generated code) or inline? diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 923ea7db7c..60481ec9d0 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -667,6 +667,13 @@ class RouteSetTests < Test::Unit::TestCase rs.normal ':controller/:action/:id' end end + + def test_changing_controller + assert_equal ['admin/stuff/show/10', {}], rs.generate( + {:controller => 'stuff', :action => 'show', :id => 10}, + {:controller => 'admin/user', :action => 'index'} + ) + end end end |