Exception: Mongoid::Errors::Validations

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/mongoid/errors.rb

Overview

Raised when a persisence method ending in ! fails validation. The message will contain the full error messages from the Document in question.

Example:

Validations.new(person.errors)

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ Validations

Returns a new instance of Validations.



65
66
67
# File 'lib/mongoid/errors.rb', line 65

def initialize(errors)
  @errors = errors
end

Instance Method Details

#messageObject



68
69
70
# File 'lib/mongoid/errors.rb', line 68

def message
  "Validation Failed: #{@errors.full_messages.join(", ")}"
end