aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-09-04 20:09:15 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-09-04 20:09:15 +0000
commit40762a48732185ce344cde351dfc6f4a67941f09 (patch)
treeea6b92acbe7013525e12fba22eb1a3db87d1367e /actionpack
parentdf70e28e037952c8dee8e66b3ae683e5976e4f1d (diff)
downloadrails-40762a48732185ce344cde351dfc6f4a67941f09.tar.gz
rails-40762a48732185ce344cde351dfc6f4a67941f09.tar.bz2
rails-40762a48732185ce344cde351dfc6f4a67941f09.zip
Fixed default routing NoMethodError downcase for nil when default controller provided (closes #5400) [kajism@yahoo.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4998 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/routing.rb7
-rw-r--r--actionpack/test/controller/routing_test.rb9
2 files changed, 14 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 7b9bbc3b5a..ab15e66e5c 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -556,8 +556,11 @@ module ActionController
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
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 05d2a70f1c..3ce011c178 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -1286,6 +1286,15 @@ class RouteSetTest < Test::Unit::TestCase
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|