Class: Ability

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

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Ability

Returns a new instance of Ability.



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

def initialize(user)
  can :read, User
  can :read, Rtcl::Article, is_private: false

  return unless user.present?

  can :manage, Rtcl::Article, author: user
  can :manage, Polivalente::Comment, user: user
  can :manage, User, id: user.id

  return unless user.is_admin?

  can :create, Rtcl::Article
end