diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 15:42:40 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 15:42:40 +0000 |
commit | 7e745f3aa5de4e117758ee92e2ca92aa265c6deb (patch) | |
tree | a98c346b62f52b4cf8197086ae8b731a3695c5f3 /actionpack/lib | |
parent | 6cd3bda32f6183f2e31a3b62e35c01655e8debc4 (diff) | |
download | rails-7e745f3aa5de4e117758ee92e2ca92aa265c6deb.tar.gz rails-7e745f3aa5de4e117758ee92e2ca92aa265c6deb.tar.bz2 rails-7e745f3aa5de4e117758ee92e2ca92aa265c6deb.zip |
Added to_param call for parameters when composing an url using url_for from something else than strings #812 [Sam Stephenson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@935 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index c021d88ca9..20bc6c8cae 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -64,9 +64,9 @@ module ActionController if value.nil? || item == :controller value elsif collection - CGI.escape(value.to_s).gsub(/%2F/, "/") + Routing.extract_parameter_value(value).gsub(/%2F/, "/") else - CGI.escape(value.to_s) + Routing.extract_parameter_value(value) end else item @@ -316,6 +316,11 @@ module ActionController end end + def self.extract_parameter_value(parameter) + value = parameter.respond_to?(:to_param) ? parameter.to_param : parameter.to_s + CGI.escape(value) + end + def self.draw(*args, &block) #:nodoc: Routes.draw(*args) {|*args| block.call(*args)} end diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 6c51ef3f3e..bbfa6009a4 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -95,7 +95,7 @@ module ActionController key = CGI.escape key key += '[]' if value.class == Array value = [ value ] unless value.class == Array - value.each { |val| elements << "#{key}=#{CGI.escape(val.to_s)}" } + value.each { |val| elements << "#{key}=#{Routing.extract_parameter_value(val)}" } end query_string << ("?" + elements.join("&")) unless elements.empty? |