123456789_123456789_123456789_123456789_123456789_

Exception: Mongoid::Errors::Validations

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, MongoidError, StandardError
Instance Chain:
self, MongoidError, StandardError
Inherits: Mongoid::Errors::MongoidError
Defined in: lib/mongoid/errors/validations.rb

Overview

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

Examples:

Create the error.

Validations.new(person.errors)

Constant Summary

MongoidError - Inherited

BASE_KEY

Class Method Summary

Instance Attribute Summary

MongoidError - Inherited

Instance Method Summary

MongoidError - Inherited

#compose_message

Compose the message.

#translate

Given the key of the specific error and the options hash, translate the message.

#translate_problem

Create the problem.

#translate_resolution

Create the resolution.

#translate_summary

Create the summary.

Constructor Details

.new(document) ⇒ Validations

[ GitHub ]

  
# File 'lib/mongoid/errors/validations.rb', line 16

def initialize(document)
  @document = document

  super(
    compose_message(
      "validations",
      {
        document: document.class,
        errors: document.errors.full_messages.join(", ")
      }
    )
  )
end

Instance Attribute Details

#document (readonly) Also known as: #record

[ GitHub ]

  
# File 'lib/mongoid/errors/validations.rb', line 13

attr_reader :document

#record (readonly)

Alias for #document.

[ GitHub ]

  
# File 'lib/mongoid/errors/validations.rb', line 14

alias :record :document