Class: Ability

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
app/models/ability.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user) ⇒ Ability

Returns a new instance of Ability.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/ability.rb', line 4

def initialize(current_user)
  can :read, :all
  can :manage, UserSession

  if current_user
    # Abilities for someone with an account (does not necessarily have a "user" role)
    can [:update, :destroy], User do |user|
      user == current_user
    end


    # User role abilities
    if current_user.is_user?
    end


    # Moderator role abilities
    if current_user.is_moderator?
    end


    # Admin role abilities
    if current_user.is_admin?
      can :manage, :all
    end


    # Developer role abilities
    if current_user.is_developer?
      can :manage, :all
    end
  else
    can :create, User
  end

end