Class: Abilities::ThecoreAuthCommons

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
lib/abilities/thecore_auth_commons.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ ThecoreAuthCommons

Returns a new instance of ThecoreAuthCommons.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/abilities/thecore_auth_commons.rb', line 4

def initialize user
    # Main abilities file for Thecore applications
    if user.present?
        # Users' abilities
        # -
        if user.admin?
            # Admins' abiities
            can :manage, :all # only allow admin users to access Rails Admin
            cannot :destroy, User do |u|
                # prevents killing himself
                u.id == user.id
            end
        end
    end
end