instance method
url_options
Ruby on Rails edge
Since v3.0.20Signature
url_options()
No documentation comment.
Source
# File actionpack/lib/action_controller/metal/url_for.rb, line 36
def url_options
@_url_options ||= {
host: request.host,
port: request.optional_port,
protocol: request.protocol,
_recall: request.path_parameters,
**super,
}.freeze
if (same_origin = _routes.equal?(request.routes)) ||
(script_name = request.engine_script_name(_routes)) ||
(original_script_name = request.original_script_name)
if original_script_name
{ **@_url_options, original_script_name: original_script_name }.freeze
else
effective_script_name = same_origin ? request.script_name : script_name
# Memoized per script_name value, compared on every call: the
# script name only changes around engine dispatch, but a stale
# hash must never be served if it does.
cached = @_url_options_with_script_name
if cached && cached[:script_name] == effective_script_name
cached
else
script_name = effective_script_name.empty? ? "" : effective_script_name.dup
@_url_options_with_script_name = { **@_url_options, script_name: script_name }.freeze
end
end
else
@_url_options
end
end
Defined in actionpack/lib/action_controller/metal/url_for.rb line 36
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::UrlFor