Skip to content
Browse files

Fix empty url_for with nested modules #707

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@782 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 74d5f6e commit b7889524bfe861e38aa7f384ed116f2b15068fe1 @dhh dhh committed Feb 24, 2005
Showing with 8 additions and 2 deletions.
  1. +3 −2 actionpack/lib/action_controller/routing.rb
  2. +5 −0 actionpack/test/controller/routing_tests.rb
View
5 actionpack/lib/action_controller/routing.rb
@@ -215,8 +215,9 @@ def generate(options, request)
options = options.symbolize_keys
defaults = request.path_parameters.symbolize_keys
- options = defaults if options.empty? # Get back the current url if no options was passed
- expand_controller_path!(options, defaults)
+ if options.empty? then options = defaults.clone # Get back the current url if no options was passed
+ else expand_controller_path!(options, defaults) # Expand the supplied controller path.
+ end
defaults.delete_if {|k, v| options.key?(k) && options[k].nil?} # Remove defaults that have been manually cleared using :name => nil
failures = []
View
5 actionpack/test/controller/routing_tests.rb
@@ -474,6 +474,11 @@ def test_default_dropped_with_nil_option
@request.path_parameters = {:controller => 'content', :action => 'action', :id => '10'}
verify_generate 'content/action', {:id => nil}
end
+
+ def test_url_to_self
+ @request.path_parameters = {:controller => 'admin/users', :action => 'index'}
+ verify_generate 'admin/users', {}
+ end
end
#require '../assertions/action_pack_assertions.rb'

0 comments on commit b788952

Please sign in to comment.
Something went wrong with that request. Please try again.