diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-04-29 22:51:04 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-04-29 22:51:04 +0100 |
commit | 6cad40762321a1436d9c9c5a2175e832486d4613 (patch) | |
tree | e6fb2a5026b949d4b5f86ebbe21fe367e528c20b /actionpack/lib | |
parent | 4075a394530da0c4a88507519f6e6f8b30073cf8 (diff) | |
download | rails-6cad40762321a1436d9c9c5a2175e832486d4613.tar.gz rails-6cad40762321a1436d9c9c5a2175e832486d4613.tar.bz2 rails-6cad40762321a1436d9c9c5a2175e832486d4613.zip |
Restore interpolation of path option in redirect routes
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/redirection.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index 866a2f5602..dc28389360 100644 --- a/actionpack/lib/action_dispatch/routing/redirection.rb +++ b/actionpack/lib/action_dispatch/routing/redirection.rb @@ -1,4 +1,5 @@ require 'action_dispatch/http/request' +require 'active_support/core_ext/uri' require 'rack/utils' module ActionDispatch @@ -47,8 +48,17 @@ module ActionDispatch :params => request.query_parameters }.merge options + if !params.empty? && url_options[:path].match(/%\{\w*\}/) + url_options[:path] = (url_options[:path] % escape_path(params)) + end + ActionDispatch::Http::URL.url_for url_options end + + private + def escape_path(params) + Hash[params.map{ |k,v| [k, URI.parser.escape(v)] }] + end end module Redirection |