Sha256: 4995c35c120c9b3ef538ad527ba48b4553ccb6fdadf4f7b998d26a8662f00cc3
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 KB
Contents
module CanCan # A general CanCan exception class Error < StandardError; end # Raised when removed code is called, an alternative solution is provided in message. class ImplementationRemoved < Error; end # This error is raised when a user isn't allowed to access a given controller action. # This usually happens within a call to ControllerAdditions#authorize! but can be # raised manually. # # raise CanCan::AccessDenied.new("Not authorized!", :read, Article) # # The passed message, action, and subject are optional and can later be retrieved when # rescuing from the exception. # # exception.message # => "Not authorized!" # exception.action # => :read # exception.subject # => Article # # If the message is not specified (or is nil) it will default to "You are not authorized # to access this page." This default can be overridden by setting default_message. # # exception.default_message = "Default error message" # exception.message # => "Default error message" # # See ControllerAdditions#authorized! for more information on rescuing from this exception. class AccessDenied < Error attr_reader :action, :subject attr_writer :default_message def initialize(message = nil, action = nil, subject = nil) @message = message @action = action @subject = subject @default_message = "You are not authorized to access this page." end def to_s @message || @default_message end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cancan-1.3.4 | lib/cancan/exceptions.rb |
cancan-1.3.3 | lib/cancan/exceptions.rb |
cancan-1.3.2 | lib/cancan/exceptions.rb |
cancan-1.2.0 | lib/cancan/exceptions.rb |