Exception: Rango::Exceptions::Redirection

Inherits:
HttpError
  • Object
show all
Defined in:
lib/rango/exceptions.rb

Overview

redirection

Instance Attribute Summary

Attributes inherited from HttpError

#backtrace, #message, #status

Instance Method Summary collapse

Methods inherited from HttpError

headers, #headers, #inspect, message, message=, name, #name, name=, status, status=, #to_snakecase

Constructor Details

#initialize(location, status = nil) ⇒ Redirection

use raise MovedPermanently, “example.com” Yes, you can use just redirect method from the controller, but this will work even in filters or in environments without controllers raise Redirection.new(“/”, 301)



130
131
132
133
134
# File 'lib/rango/exceptions.rb', line 130

def initialize(location, status = nil)
  super(location, status)
  location = URI.escape(location)
  headers["Location"] = location
end

Instance Method Details

#bodyObject



116
117
118
# File 'lib/rango/exceptions.rb', line 116

def body
  %{Please follow <a href="#{URI.escape(self.location)}">#{self.location}</a>}
end

#to_responseObject



120
121
122
123
124
# File 'lib/rango/exceptions.rb', line 120

def to_response
  super.tap do |response|
    response[2] = [self.body]
  end
end