method

to_xml

rails latest stable - Class: ActiveModel::Errors

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v6.1.7.7) is shown here.

to_xml(options = {})
public

Returns an xml formatted representation of the Errors hash.

person.errors.add(:name, :blank, message: "can't be blank")
person.errors.add(:name, :not_specified, message: "must be specified")
person.errors.to_xml
# =>
#  <?xml version=\"1.0\" encoding=\"UTF-8\"?>
#  <errors>
#    <error>name can't be blank</error>
#    <error>name must be specified</error>
#  </errors>