Exception: Mongoid::Errors::MongoidError

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

Overview

Default parent Mongoid error for all custom errors. This handles the base key for the translations and provides the convenience method for translating the messages.

Constant Summary collapse

BASE_KEY =
"mongoid.errors.messages"

Instance Method Summary collapse

Instance Method Details

#translate(key, options) ⇒ Object

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

Options:

key: The key of the error in the locales. options: The objects to pass to create the message.

Returns:

A localized error message string.



22
23
24
# File 'lib/mongoid/errors/mongoid_error.rb', line 22

def translate(key, options)
  ::I18n.translate("#{BASE_KEY}.#{key}", options)
end