obdev/app/models/ability.rb

17 lines
344 B
Ruby

# frozen_string_literal: true
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.has_role? :admin
can :manage, :all
can :create, User if user.has_role? :admin
else
can :read, :all
# Define other abilities for other roles
end
end
end