Class: Comable::Ability

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

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Ability

Returns a new instance of Ability.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/models/comable/ability.rb', line 5

def initialize(user)
  user ||= Comable::User.new # guest user (not logged in)

  case user.role.to_sym
  when :admin
    can :manage, :all
  when :reporter
    can :read, :all
  else
    fail CanCan::AccessDenied
  end
end