Sha256: 2835a95fbe312fa9d64a8804ab270af3e6388827b018d4eae9b594fd16211f0b

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

module Pbw
  class ApplicationController < ActionController::Base
  	  
  	  rescue_from ::CanCan::AccessDenied do |exception|
	    flash[:alert] = "Access denied. You are not authorized to access the requested page."
	    respond_to do |format|
	    	format.json {render json: flash[:alert], status: 401}
	    	format.html {redirect_to root_path}
	    end
	  end

	  protected

	  def self.permission
	    return name = self.name.gsub('Controller','').singularize.split('::').last.constantize.name rescue nil
	  end

	  def current_ability
	    @current_ability ||= Ability.new(current_user)
	  end

	  def load_permissions
	    @current_permissions = current_user.role.permissions.collect{|i| [i.subject_class, i.action]}
	  end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pbw-0.0.2 app/controllers/pbw/application_controller.rb