Method: ActiveModel::Errors#to_xml
- Defined in:
- lib/active_model/errors.rb
#to_xml(options = {}) ⇒ Object
Returns an xml formatted representation of the Errors hash.
p.errors.add(:name, "can't be blank")
p.errors.add(:name, "must be specified")
p.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>
214 215 216 |
# File 'lib/active_model/errors.rb', line 214 def to_xml(={}) to_a.to_xml .reverse_merge(:root => "errors", :skip_types => true) end |