class DataMapper::Validations::ValidationErrors

Monkey-patch ValidationErrors to support generation of error message from a Symbol. This does not translate, consistent with normal DataMapper operation. Set DataMapper::Validate::ValidationErrors.default_error_messages if alternate messages are needed (after devise has been initialized).

Public Instance Methods

add(field_name, message = nil) click to toggle source

If the message is a Symbol, allow default_error_message to generate the message, including translation.

# File lib/devise/orm/data_mapper/validations/dm-validations.rb, line 14
def add(field_name, message = nil)
  if message.kind_of?(Symbol)
    message = self.class.default_error_message(message, field_name)
  end
  original_add(field_name, message) unless errors[field_name].include?(message)
end
Also aliased as: original_add
original_add(field_name, message = nil) click to toggle source
Alias for: add
to_xml(options = {}) click to toggle source

Some devise controller actions expect resourceerrors to respond to to_xml. Otherwise, we get a Missing template error

# File lib/devise/orm/data_mapper/validations/dm-validations.rb, line 23
def to_xml(options = {})
  @errors.to_hash.to_xml(options.merge(:root => 'errors'))
end