diff options
author | thedarkone <thedarkone2@gmail.com> | 2010-09-27 15:11:19 +0200 |
---|---|---|
committer | thedarkone <thedarkone2@gmail.com> | 2010-09-27 17:45:59 +0200 |
commit | 8fdb34b2373b13eee24a403a3af398cddb2a5ad0 (patch) | |
tree | e285cda16670b8f085cc29a899491a481e4c557e | |
parent | 86bcccf8dfced5e9428407a71f02c1dcc186f2ba (diff) | |
download | rails-8fdb34b2373b13eee24a403a3af398cddb2a5ad0.tar.gz rails-8fdb34b2373b13eee24a403a3af398cddb2a5ad0.tar.bz2 rails-8fdb34b2373b13eee24a403a3af398cddb2a5ad0.zip |
Cache url_options on a per-request basis.
-rw-r--r-- | actionpack/lib/action_controller/metal/url_for.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb index 85c6b0a9b5..ef1071bb3d 100644 --- a/actionpack/lib/action_controller/metal/url_for.rb +++ b/actionpack/lib/action_controller/metal/url_for.rb @@ -5,16 +5,18 @@ module ActionController include AbstractController::UrlFor def url_options - options = {} - if _routes.equal?(env["action_dispatch.routes"]) - options[:script_name] = request.script_name.dup - end + @_url_options ||= begin + options = {} + if _routes.equal?(env["action_dispatch.routes"]) + options[:script_name] = request.script_name.dup + end - super.merge(options).reverse_merge( - :host => request.host_with_port, - :protocol => request.protocol, - :_path_segments => request.symbolized_path_parameters - ) + super.merge(options).reverse_merge( + :host => request.host_with_port, + :protocol => request.protocol, + :_path_segments => request.symbolized_path_parameters + ).freeze + end end end end |