Skip to content

Instantly share code, notes, and snippets.

@neaf
Created March 16, 2010 10:38
Show Gist options
  • Select an option

  • Save neaf/333833 to your computer and use it in GitHub Desktop.

Select an option

Save neaf/333833 to your computer and use it in GitHub Desktop.
# encoding: utf-8
# http://wiki.github.com/botanicus/rango/controllers
require "rango/helpers"
require "rango/controller"
require "rango/mixins/rendering"
module Ark
class Application < Rango::Controller
include Rango::Exceptions
include Rango::Helpers
include Rango::ImplicitRendering
# http://wiki.github.com/botanicus/rango/errors-handling
def render_http_error(exception)
if self.respond_to?(exception.to_snakecase)
self.send(exception.to_snakecase, exception)
else
begin
return exception.status.to_s
render "errors/#{exception.status}.html"
rescue TemplateNotFound
render "errors/500.html"
end
end
end
def warden
request.env["warden"]
end
def authenticated?(*args)
warden.authenticated?(*args)
end
alias_method :logged_in?, :authenticated?
def authorize!
return if warden.authenticated?
session[:redirect_to] = request.path
redirect url(:login)
end
def current_user(*args)
warden.user(*args)
end
def current_user=(new_user)
warden.set_user(new_user)
end
def flash
request.env["x-rack.flash"]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment