Skip to content

Instantly share code, notes, and snippets.

@pedrosmmoreira
Created February 17, 2017 11:20
Show Gist options
  • Save pedrosmmoreira/fbb2b9086cfae824ca0293fef8ef9bd9 to your computer and use it in GitHub Desktop.
Save pedrosmmoreira/fbb2b9086cfae824ca0293fef8ef9bd9 to your computer and use it in GitHub Desktop.
class AdminFooPolicy < ApplicationPolicy
class Scope
attr_reader :user, :scope
def initialize(user, context)
@user = user
@scope = context.record
end
def resolve
scope.not_cancelled?
end
end
def initialize(user, context)
@user = user
@record = context.record
end
def show?
!record.cancelled?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment