app/policies/unit_policy.rb
# frozen_string_literal: true
class UnitPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user&.admin?
scope.all
else
raise Pundit::NotAuthorizedError
end
end
end
def create?
user&.admin?
end
def update?
user&.admin?
end
def destroy?
user&.admin?
end
end