提交 8fdb34b2 编写于 作者: T thedarkone

Cache url_options on a per-request basis.

上级 86bcccf8
......@@ -5,16 +5,18 @@ module UrlFor
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册