Class: Rostra::Ability

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
app/models/rostra/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
17
18
19
20
21
# File 'app/models/rostra/ability.rb', line 5

def initialize(user)
  @user = user || User.new

  if @user.can_participate_in_rostra?
    can :manage, Question, :user => user
    can :manage, Answer, :user => user
    can :manage, Comment, :user => user

    can [:vote, :toggle_following], Question
    cannot :vote, Question, :user => user

    can [:vote], Answer
    cannot :vote, Answer, :user => user
  end

  can :read, :all
end