Sha256: 75807cae2bebae63d7844ac99e54c547279f7902669158420e3050f2ec9942f9

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 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
    
  private
  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
jrun-rails_doorman-0.0.1 spec/fixtures/app/app/controllers/application_controller.rb