Created
June 3, 2016 15:46
-
-
Save lukeredpath/e19438b817224c0437bb78b176090233 to your computer and use it in GitHub Desktop.
Defining Pundit policies without delegating to roles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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