Class: Mongoid::Errors::Validations

Inherits:
Object
  • Object
show all
Defined in:
lib/egregious/extensions/mongoid.rb

Instance Method Summary collapse

Instance Method Details

#to_jsonObject



20
21
22
# File 'lib/egregious/extensions/mongoid.rb', line 20

def to_json
  "{\"error\":#{ActiveSupport::JSON.encode(self.document.errors.full_messages.join(', ').gsub(/\r/, ' ').gsub(/\n/, ' ').squeeze(' '))}, \"type\":\"#{self.exception_type}\"}"
end

#to_xmlObject



16
17
18
# File 'lib/egregious/extensions/mongoid.rb', line 16

def to_xml
  "<errors><error>#{HTMLEntities.new.encode(self.document.errors.full_messages.join(', ').gsub(/\r/, ' ').gsub(/\n/, ' ').squeeze(' '))}</error><type>#{self.exception_type}</type></errors>"
end