aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorNicholas Rowe <nixterrimus@gmail.com>2011-02-20 21:35:43 -0500
committerNicholas Rowe <nixterrimus@gmail.com>2011-02-20 21:35:43 -0500
commit34316d8b7e6b830e97ebbe124ac6d9a19ce77d2d (patch)
treece5c080a5c092d413638200a834dcae69bc9193c /activemodel
parentb014f822e57dec46d52e83519b43f838169253e8 (diff)
downloadrails-34316d8b7e6b830e97ebbe124ac6d9a19ce77d2d.tar.gz
rails-34316d8b7e6b830e97ebbe124ac6d9a19ce77d2d.tar.bz2
rails-34316d8b7e6b830e97ebbe124ac6d9a19ce77d2d.zip
Docs: Update to_xml documentation to match as_json docuemntation
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/serializers/xml.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb
index b897baa614..0b0116d32c 100644
--- a/activemodel/lib/active_model/serializers/xml.rb
+++ b/activemodel/lib/active_model/serializers/xml.rb
@@ -134,6 +134,31 @@ module ActiveModel
# Returns XML representing the model. Configuration can be
# passed through +options+.
+ #
+ # Without any +options+, the returned XML string will include all the model's
+ # attributes. For example:
+ #
+ # konata = User.find(1)
+ # konata.to_xml
+ #
+ # <?xml version="1.0" encoding="UTF-8"?>
+ # <user>
+ # <id type="integer">1</id>
+ # <name>David</name>
+ # <age type="integer">16</age>
+ # <created-at type="datetime">2011-01-30T22:29:23Z</created-at>
+ # </user>
+ #
+ # The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the attributes
+ # included, and work similar to the +attributes+ method.
+ #
+ # To include the result of some method calls on the model use <tt>:methods</tt>
+ #
+ # To include associations use <tt>:include</tt>
+ #
+ # For further documentation see activerecord/lib/active_record/serializers/xml_serializer.xml
+
+
def to_xml(options = {}, &block)
Serializer.new(self, options).serialize(&block)
end