panter/mykonote

View on GitHub
app/policies/note_policy.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class NotePolicy < ApplicationPolicy
  def index?
    true
  end

  def show?
    record.user == user
  end

  def create?
    true
  end

  def new?
    create?
  end

  def update?
    record.user == user
  end

  def edit?
    update?
  end

  def destroy?
    record.user == user
  end

  class Scope < Scope
    def resolve
      scope.where(user: user)
    end
  end
end