diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 22:44:12 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 22:44:12 +0000 |
commit | 0919dbf6b63a4aaa49a2855c37e79a90937290e1 (patch) | |
tree | 7aae25e7f745f5f56ef51446a50320d5e97b7a34 | |
parent | 20e3cfe52d294893ad46307440e4acf1f02165ea (diff) | |
download | rails-0919dbf6b63a4aaa49a2855c37e79a90937290e1.tar.gz rails-0919dbf6b63a4aaa49a2855c37e79a90937290e1.tar.bz2 rails-0919dbf6b63a4aaa49a2855c37e79a90937290e1.zip |
Routes: Convert results of #to_param to strings #879
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@947 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/routing_tests.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 20bc6c8cae..0e97b7174f 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -317,7 +317,7 @@ module ActionController end def self.extract_parameter_value(parameter) - value = parameter.respond_to?(:to_param) ? parameter.to_param : parameter.to_s + value = (parameter.respond_to?(:to_param) ? parameter.to_param : parameter).to_s CGI.escape(value) end diff --git a/actionpack/test/controller/routing_tests.rb b/actionpack/test/controller/routing_tests.rb index 744ccb1093..f36e395107 100644 --- a/actionpack/test/controller/routing_tests.rb +++ b/actionpack/test/controller/routing_tests.rb @@ -346,6 +346,13 @@ class RouteTests < Test::Unit::TestCase verify_generate('id%2Fwith%2Fslashes', {}, {:controller => 'content', :action => 'fish', :id => 'id/with/slashes'}, {}) end + + def test_generate_with_numeric_param + o = Object.new + def o.to_param() 10 end + verify_generate('content/action/10', {}, {:controller => 'content', :action => 'action', :id => o}, @defaults) + verify_generate('content/show/10', {}, {:controller => 'content', :action => 'show', :id => o}, @defaults) + end end class RouteSetTests < Test::Unit::TestCase |