Slide 37
Slide 37 text
CANCAN
class Ability
include CanCan ::Ability
def user_abilities
can :create, [Question, Answer]
can :update, [Question, Answer], user_id: user.id
can :destroy, [Question, Answer], user_id: user.id
can :destroy, Attachment, attachable: { user_id: user.id }
can [:vote_up, :vote_down], [Question, Answer] do |resource|
resource.user_id != user.id
end
end
end