Module: Redirect

Included in:
Rambo::Controller
Defined in:
lib/rambo/controller/redirect.rb

Instance Method Summary collapse

Instance Method Details

#redirect(destination, options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rambo/controller/redirect.rb', line 2

def redirect(destination, options={})
  destination = destination.to_s if destination.is_a? Symbol
  unless destination[0,1] == "/" or destination =~ /^http:\/\// or destination =~ /^file:\/\//
    destination = "/#{self.controller}/#{destination}"
  end
  puts "redirecting to #{destination}"
  
  @rendered = true
  response.status = 302
  response.header['Location'] = destination
  return ""
end