Sha256: 5330fcb62cce9c53f4f60cb7fa371041cd804108cc5201fbd19a0a57dce75752

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
  filter_parameter_logging :password

  helper_method :current_user
  
  def self.nil_current_user
    self.current_user = nil
  end

  def self.reset_current_user
    self.current_user ||= User.new
    self.current_user.reset
  end
  
  protected
  cattr_accessor :current_user
  self.current_user ||= User.new
  
  
  def rescue_action_in_public(exception)
    case exception
    when Doorman::InvalidRule
      render :text => 'Invalid Rule', :status => '500 Internal Server Error'
    when Doorman::Unauthorized
      render :text => 'Unauthorized', :status => '401 Unauthorized'
    else
      super(exception)
    end
  end
  
  alias :rescue_action_locally :rescue_action_in_public
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-doorman-0.1.0 spec/fixtures/app/app/controllers/application_controller.rb