class Pundit::NotAuthorizedError
Error
that will be raised when authorization has failed
Attributes
@see initialize
@see initialize
@see initialize
Public Class Methods
Source
# File lib/pundit.rb, line 51 def initialize(options = {}) if options.is_a? String message = options else @query = options[:query] @record = options[:record] @policy = options[:policy] message = options.fetch(:message) do record_name = record.is_a?(Class) ? record.to_s : "this #{record.class}" "not allowed to #{policy.class}##{query} #{record_name}" end end super(message) end
@overload initialize(message)
Create an error with a simple error message. @param [String] message A simple error message string.
@overload initialize(options)
Create an error with the specified attributes. @param [Hash] options The error options. @option options [String] :message Optional custom error message. Will default to a generalized message. @option options [Symbol] :query The name of the policy method that was checked. @option options [Object] :record The object that was being checked with the policy. @option options [Class] :policy The class of policy that was used for the check.
Calls superclass method