app/policies/category_policy.rb
# frozen_string_literal: true
class CategoryPolicy < ApplicationPolicy
attr_reader :user, :category
def initialize(user, category)
@user = user
@category = category
end
def new?
authorized?
end
def create?
authorized?
end
def edit?
authorized?
end
def update?
authorized?
end
def destroy?
authorized?
end
private
def authorized?
user.admin? || user.volunteer?
end
end