Friday, September 20, 2024 12:02:43 AM
> settings

Customize


Authenticate

> project_policy.rb
# frozen_string_literal: true

class ProjectPolicy < ApplicationPolicy
  class Scope < Scope
    def resolve
      table = Project.arel_table
      value = current_user.role.value

      role_check = (table[:role_visibility] & value).eq(value)

      scope.where(role_check.to_sql)
    end
  end

  def index?
    current_user.permission?(:project_view)
  end

  def show?
    index?
  end
end
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b