Skip to content

Commit

Permalink
Fixed default routing NoMethodError downcase for nil when default con…
Browse files Browse the repository at this point in the history
…troller provided (closes #5400) [kajism@yahoo.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4998 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Sep 4, 2006
1 parent df70e28 commit 40762a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions actionpack/lib/action_controller/routing.rb
Expand Up @@ -556,8 +556,11 @@ def extract_value
end

def match_extraction(next_capture)
hangon = (default ? "|| #{default.inspect}" : "if match[#{next_capture}]")
"params[:#{key}] = match[#{next_capture}].downcase #{hangon}"
if default
"params[:#{key}] = match[#{next_capture}] ? match[#{next_capture}].downcase : '#{default}'"
else
"params[:#{key}] = match[#{next_capture}].downcase if match[#{next_capture}]"
end
end
end

Expand Down
9 changes: 9 additions & 0 deletions actionpack/test/controller/routing_test.rb
Expand Up @@ -1286,6 +1286,15 @@ def test_draw_default_route
end
end

def test_draw_default_route_with_default_controller
ActionController::Routing.with_controllers(['users']) do
set.draw do |map|
map.connect '/:controller/:action/:id', :controller => 'users'
end
assert_equal({:controller => 'users', :action => 'index'}, set.recognize_path('/'))
end
end

def test_route_with_parameter_shell
ActionController::Routing.with_controllers(['users', 'pages']) do
set.draw do |map|
Expand Down

0 comments on commit 40762a4

Please sign in to comment.