The current user model is passed to the Ability#initialize
, so you can just check its class:
class Ability
include CanCan::Ability
def initialize(model)
case model
when Admin
can :manage, :all
when User
can :create, Comment
can :read, :all
else
can :read, :all
end
end
end