aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-04-29 23:12:42 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2012-04-29 23:19:23 +0100
commit75df4c11650a148f6672ce6407b624b840ec7b50 (patch)
tree7247deaaf4ec92971e46480f5ec633a4ea44762c /actionpack/lib/action_dispatch
parentc19acab866a48d57655132f33ab224b59d87685b (diff)
downloadrails-75df4c11650a148f6672ce6407b624b840ec7b50.tar.gz
rails-75df4c11650a148f6672ce6407b624b840ec7b50.tar.bz2
rails-75df4c11650a148f6672ce6407b624b840ec7b50.zip
Restore interpolation of path option in redirect routes
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/redirection.rb10
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 f4084d9f4f..444a79c50d 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