- D
- E
- H
- O
- P
- R
- S
- U
# File actionpack/lib/action_dispatch/http/url.rb, line 23 def url_for(options = {}) unless options[:host].present? || options[:only_path].present? raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true' end rewritten_url = "" unless options[:only_path] unless options[:protocol] == false rewritten_url << (options[:protocol] || "http") rewritten_url << ":" unless rewritten_url.match(%r{:|//}) end rewritten_url << "//" unless rewritten_url.match("//") rewritten_url << rewrite_authentication(options) rewritten_url << host_or_subdomain_and_domain(options) rewritten_url << ":#{options.delete(:port)}" if options[:port] end path = options.delete(:path) || '' params = options[:params] || {} params.reject! {|k,v| v.to_param.nil? } rewritten_url << (options[:trailing_slash] ? path.sub(%r\?|\z/) { "/" + $& } : path) rewritten_url << "?#{params.to_query}" unless params.empty? rewritten_url << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor] rewritten_url end
Returns the domain part of a host, such as “rubyonrails.org” in “www.rubyonrails.org”. You can specify
a different tld_length
, such as 2 to catch rubyonrails.co.uk
in “www.rubyonrails.co.uk”.
Returns the host for this request, such as example.com.
Returns a host:port string for this request, such as “example.com” or “example.com:8080”.
Returns a number port suffix like 8080 if the port number of this request is not the default HTTP port 80 or HTTPS port 443.
Returns the port number of this request as an integer.
Returns a string port suffix, including colon, like “:8080” if the port number of this request is not the default HTTP port 80 or HTTPS port 443.
Returns ‘https://’ if this is an SSL request and ‘http://’ otherwise.
Returns the host for this request, such as “example.com”.
Returns the standard port number for this request’s protocol.
Returns whether this request is using the standard port
Returns all the subdomains as a string, so "dev.www"
would be returned for “dev.www.rubyonrails.org”. You can specify a
different tld_length
, such as 2 to catch
"www"
instead of
"www.rubyonrails"
in “www.rubyonrails.co.uk”.
Returns all the subdomains as an array, so ["dev",
"www"]
would be returned for “dev.www.rubyonrails.org”.
You can specify a different tld_length
, such as 2 to catch
["www"]
instead of ["www",
"rubyonrails"]
in “www.rubyonrails.co.uk”.