Created
February 17, 2017 11:23
-
-
Save pedrosmmoreira/c93c4786fc5c24d209dedd25bad72f8b to your computer and use it in GitHub Desktop.
This file contains 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 FoosController < ApplicationController | |
include Pundit | |
#... | |
# record policy | |
def set_record_policy | |
policy(PolicyContext.new(record, current_user) | |
end | |
# scope policy | |
def set_policy_scope | |
policy_scope(PolicyContext.new(RecordClassName, current_user)) | |
end | |
# authorizing controller action | |
def authorize_action | |
authorize PolicyContext.new(record, user), "#{action_name}?" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment