Slide 22
Slide 22 text
app/models/ability.rb
class Ability
include CanCan::Ability
def initialize(user)
@user = user
if user
public_send user.role
else
guest
end
end
def guest
can [:show, :update], Invite
end
...
...
def registered
can :read, :all
can :manage, Book do |book|
book.team_id == @user.team.id
end
end
def admin
can :manage, :all
end
end