Permalink
Browse files

Don't ignore :controller for urls made inside a controller module #1526

… [Nicholas Seckar]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1542 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a7116b6 commit b8689c77a49df98802ec04ca60c9602fa092385c @dhh dhh committed Jun 27, 2005
Showing with 11 additions and 2 deletions.
  1. +4 −2 actionpack/lib/action_controller/routing.rb
  2. +7 −0 actionpack/test/controller/routing_test.rb
@@ -360,8 +360,10 @@ def initialize
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?
@@ -667,6 +667,13 @@ def test_named_route_without_hash
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

0 comments on commit b8689c7

Please sign in to comment.