Sha256: 7a4753ceb98ddbdd33386dab6b7ffad007bfaf8f43a01a859478606db6be3246
Contents?: true
Size: 903 Bytes
Versions: 6
Compression:
Stored size: 903 Bytes
Contents
if Object.const_defined?("Pundit") module Administrate module Punditize extend ActiveSupport::Concern include Pundit included do def scoped_resource policy_scope_admin super end def authorize_resource(resource) authorize resource end def show_action?(action, resource) Pundit.policy!(pundit_user, resource).send("#{action}?".to_sym) end end private # Like the policy_scope method in stock Pundit, but allows the 'resolve' # to be overridden by 'resolve_admin' for a different index scope in Admin # controllers. def policy_scope_admin(scope) ps = Pundit::PolicyFinder.new(scope).scope!.new(pundit_user, scope) if ps.respond_to? :resolve_admin ps.resolve_admin else ps.resolve end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems