module ActionDispatch::Routing::UrlFor

def _routes_context # :doc:

:doc:
def _routes_context # :doc:
  self
end

def _with_routes(routes) # :doc:

:doc:
def _with_routes(routes) # :doc:
  old_routes, @_routes = @_routes, routes
  yield
ensure
  @_routes = old_routes
end

def full_url_for(options = nil) # :nodoc:

:nodoc:
def full_url_for(options = nil) # :nodoc:
  case options
  when nil
    _routes.url_for(url_options.symbolize_keys)
  when Hash, ActionController::Parameters
    route_name = options.delete :use_route
    merged_url_options = options.to_h.symbolize_keys.reverse_merge!(url_options)
    _routes.url_for(merged_url_options, route_name)
  when String
    options
  when Symbol
    HelperMethodBuilder.url.handle_string_call self, options
  when Array
    components = options.dup
    polymorphic_url(components, components.extract_options!)
  when Class
    HelperMethodBuilder.url.handle_class_call self, options
  else
    HelperMethodBuilder.url.handle_model_call self, options
  end
end

def initialize(...)

def initialize(...)
  @_routes = nil
  super
end

def optimize_routes_generation?

def optimize_routes_generation?
  _routes.optimize_routes_generation? && default_url_options.empty?
end

def route_for(name, *args)


threadable_url(threadable) # => "http://example.com/buckets/1"
threadable_path(threadable) # => "/buckets/1"

or full URL, e.g:
This maintains the context of the original caller on whether to return a path

end
route_for(:recordable, threadable.parent)
direct :threadable do |threadable|

end
route_for(:bucket, recording.bucket)
direct :recordable do |recording|

resources :buckets

Allows calling direct or regular named route.
def route_for(name, *args)
  public_send(:"#{name}_url", *args)
end

def url_for(options = nil)

calls.
used by `url_for` can always be overwritten like shown on the last `url_for`
the helper used the one from the route's path. Any path parameter implicitly
Notice that no `:id` parameter was provided to the first `url_for` call and

url_for(only_path: true, action: 'edit', id: 2) # => '/users/2/edit'
url_for(only_path: true, action: 'edit') # => '/users/1/edit'
url_for(only_path: true) # => '/users/1'

`GET /users/1`:
placed in the path). Given that the current action has been reached through
(e.g. `:controller`, `:action`, `:id`, and any other parameters that are
Missing routes keys may be filled in from the current request's parameters

# => '/myapp/tasks/testing'
url_for controller: 'tasks', action: 'testing', host: 'somehost.org', script_name: "/myapp", only_path: true
# => 'http://somehost.org/myapp/tasks/testing'
url_for controller: 'tasks', action: 'testing', host: 'somehost.org', script_name: "/myapp"
# => 'http://somehost.org/tasks/testing?number=33'
url_for controller: 'tasks', action: 'testing', host: 'somehost.org', number: '33'
# => 'http://somehost.org/tasks/testing/'
url_for controller: 'tasks', action: 'testing', trailing_slash: true
# => '/tasks/testing#ok'
url_for controller: 'tasks', action: 'testing', host: 'somehost.org', anchor: 'ok', only_path: true
# => 'http://somehost.org:8080/tasks/testing'
url_for controller: 'tasks', action: 'testing', host: 'somehost.org', port: '8080'

to the Routes module.
Any other key (`:controller`, `:action`, etc.) given to `url_for` is forwarded


provided, prepends application path.
* `:script_name` - Specifies application path relative to domain root. If
`"/archive/2009/"`.
* `:trailing_slash` - If true, adds a trailing slash, as in
dynamic segments of path. If unused, they will be discarded.
* `:path_params` - The query parameters that will only be used for the named
* `:params` - The query parameters to be appended to the path.
* `:anchor` - An anchor name to be appended to the path.
* `:port` - Optionally specify the port to connect to.
`ActionDispatch::Http::URL.tld_length`, which in turn defaults to 1.
`:subdomain` or `:domain` are supplied. Defaults to
* `:tld_length` - Number of labels the TLD id composed of, only used if
split the domain from the host.
* `:domain` - Specifies the domain of the link, using the `tld_length` to
from the host part of the link.
to split the subdomain from the host. If false, removes all subdomains
* `:subdomain` - Specifies the subdomain of the link, using the `tld_length`
via `default_url_options`.
`:only_path` is false, this option must be provided either explicitly, or
* `:host` - Specifies the host the link should be targeted at. If
* `:protocol` - The protocol to connect to. Defaults to `"http"`.
* `:only_path` - If true, the relative URL is returned. Defaults to `false`.

routes defined in `config/routes.rb`. The following options are supported:
Generate a URL based on the options provided, `default_url_options`, and the
def url_for(options = nil)
  full_url_for(options)
end

def url_options

`default_url_options`. Application logic should not go into url_options.
Hook overridden in controller to add request information with
def url_options
  default_url_options
end