123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::Routing::OptionRedirect

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActionDispatch::Routing::Redirect
Defined in: actionpack/lib/action_dispatch/routing/redirection.rb

Class Method Summary

Redirect - Inherited

Instance Attribute Summary

Instance Method Summary

Constructor Details

This class inherits a constructor from ActionDispatch::Routing::Redirect

Instance Method Details

#inspect

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/routing/redirection.rb', line 143

def inspect
  "redirect(#{status}, #{options.map { |k, v| "#{k}: #{v}" }.join(', ')})"
end

#options

Alias for Redirect#block.

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/routing/redirection.rb', line 115

alias :options :block

#path(params, request)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/routing/redirection.rb', line 117

def path(params, request)
  url_options = {
    protocol: request.protocol,
    host: request.host,
    port: request.optional_port,
    path: request.path,
    params: request.query_parameters
  }.merge! options

  if !params.empty? && url_options[:path].match(/%\{\w*\}/)
    url_options[:path] = (url_options[:path] % escape_path(params))
  end

  unless options[:host] || options[:domain]
    if relative_path?(url_options[:path])
      url_options[:path] = "/#{url_options[:path]}"
      url_options[:script_name] = request.script_name
    elsif url_options[:path].empty?
      url_options[:path] = request.script_name.empty? ? "/" : ""
      url_options[:script_name] = request.script_name
    end
  end

  ActionDispatch::Http::URL.url_for url_options
end