Module: Lotus::Action::Redirect

Defined in:
lib/lotus/action/redirect.rb

Overview

HTTP redirect API

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#redirect_to(url, status: 302) ⇒ Object (protected)

Redirect to the given URL

Examples:

require 'lotus/controller'

class Create
  include Lotus::Action

  def call(params)
    # ...
    redirect_to 'http://example.com/articles/23'
  end
end

Parameters:

  • url (String)

    the destination URL

  • status (Fixnum) (defaults to: 302)

    the http code

Since:

  • 0.1.0



28
29
30
31
# File 'lib/lotus/action/redirect.rb', line 28

def redirect_to(url, status: 302)
  headers.merge!('Location' => url)
  self.status = status
end