module ActionView::RoutingUrlFor

def _routes_context #:nodoc:

:nodoc:
def _routes_context #:nodoc:
  controller
end

def optimize_routes_generation? #:nodoc:

:nodoc:
def optimize_routes_generation? #:nodoc:
  controller.respond_to?(:optimize_routes_generation?, true) ?
    controller.optimize_routes_generation? : super
end

def url_for(options = nil)

# => /users
# Specify absolute path with beginning slash
<%= url_for(action: 'index', controller: '/users') %>

# => /admin/users
# Assuming an "admin" namespace
<%= url_for(action: 'index', controller: 'users') %>

# => javascript:history.back()
# if request.env["HTTP_REFERER"] is not set or is blank
<%= url_for(:back) %>

# => http://www.example.com
# if request.env["HTTP_REFERER"] is set to "http://www.example.com"
<%= url_for(:back) %>

# => http://www.example.com
<%= url_for("http://www.example.com") %>

# => /workshops/1-workshop-name
# to_param can be re-defined in a model to provide different URL names:

# => /workshops/5
# calls @workshop.to_param which by default returns the id
<%= url_for(@workshop) %>

# => /workshops
# relies on Workshop answering a persisted? call (and in this case returning false)
<%= url_for(Workshop.new) %>

# => /testing/jump/#tax&ship
<%= url_for(action: 'jump', anchor: 'tax&ship') %>

# => /messages/play/#player
<%= url_for(action: 'play', anchor: 'player') %>

# => https://www.example.com/members/login/
<%= url_for(action: 'login', controller: 'members', only_path: false, protocol: 'https') %>

# => /books/find
<%= url_for(action: 'find', controller: 'books') %>

# => /blog/
<%= url_for(action: 'index') %>
==== Examples

Controllers passed in using the +:controller+ option will retain their namespace unless it is an absolute one.

==== Implicit Controller Namespacing

+admin_workshop_path+ you'll have to call that explicitly (it's impossible for +url_for+ to guess that route).
Workshop object will attempt to use the +workshop_path+ route. If you have a nested route, such as
trigger the named route for that record. The lookup will happen on the name of the class. So passing a
Passing a record (like an Active Record) instead of a hash as the options parameter will

==== Relying on named routes

* :password - Inline HTTP authentication (only plucked out if :user is also present).
* :user - Inline HTTP authentication (only plucked out if :password is also present).
* :protocol - Overrides the default (current) protocol if provided.
* :host - Overrides the default (current) host if provided.
is currently not recommended since it breaks caching.
* :trailing_slash - If true, adds a trailing slash, as in "/archive/2005/". Note that this
* :only_path - If true, returns the relative URL (omitting the protocol, host name, and port) (true by default unless :host is specified).
* :anchor - Specifies the anchor name to be appended to the path.
==== Options

instead of the fully qualified URL like "http://example.com/controller/action".
:only_path is true so you'll get the relative "/controller/action"
documentation for ActionController::Base#url_for). Note that by default
same options as +url_for+ in Action Controller (see the
Returns the URL for the set of +options+ provided. This takes the
def url_for(options = nil)
  case options
  when String
    options
  when nil, Hash
    options ||= {}
    options = { :only_path => options[:host].nil? }.merge!(options.symbolize_keys)
    super
  when :back
    _back_url
  when Array
    polymorphic_path(options, options.extract_options!)
  else
    polymorphic_path(options)
  end
end

def url_options #:nodoc:

:nodoc:
def url_options #:nodoc:
  return super unless controller.respond_to?(:url_options)
  controller.url_options
end