Exception: Rango::Exceptions::Redirection
- Defined in:
- lib/rango/exceptions.rb
Overview
redirection
Instance Attribute Summary
Attributes inherited from HttpError
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(location, status = nil) ⇒ Redirection
constructor
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).
- #to_response ⇒ Object
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
#body ⇒ Object
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_response ⇒ Object
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 |