Friday, September 20, 2024 12:00:37 AM
> settings

Customize


Authenticate

> application_policy.rb
# frozen_string_literal: true

class ApplicationPolicy
  attr_reader :current_user, :record

  def initialize(user, record)
    @current_user = user
    @record = record
  end

  def policy(policy)
    Pundit.policy(@current_user, policy)
  end

  def index?
    false
  end

  def show?
    false
  end

  def create?
    false
  end

  def new?
    create?
  end

  def update?
    false
  end

  def edit?
    update?
  end

  def destroy?
    false
  end

  class Scope
    attr_reader :current_user, :scope

    def initialize(user, scope)
      @current_user = user
      @scope = scope
    end

    def resolve
      raise NotImplementedError, "You must define #resolve in #{self.class}"
    end
  end
end
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b