Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
Created June 3, 2016 15:46
Show Gist options
  • Save lukeredpath/e19438b817224c0437bb78b176090233 to your computer and use it in GitHub Desktop.
Save lukeredpath/e19438b817224c0437bb78b176090233 to your computer and use it in GitHub Desktop.
Defining Pundit policies without delegating to roles
class User
def roles
[:manager, :staff]
end
def has_role?(role)
roles.include?(role)
end
end
class UserPolicy < ApplicationPolicy
def create?
user.has_role?(:manager)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment