Prev | Current Page 403 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


The default generated XML will include all attributes for the object, a type attribute for
attributes that are not of type String, and processing instructions. In addition, associations are
not expanded by default. An example of the XML for an object of our Account class would be


1
Pytel
Chad
1

The default name for the root element is the class name of the Active Record object we are
formatting. The :root option should be a string and provides you a way to override the name
of the root element:
account.to_xml(:root => "myaccount")
# =>
1
Pytel
Chad
1
2006-11-10T10:22:56-05:00

You can use the :only and :except options to explicitly include or exclude attributes from
the resulting XML:
account.


Pages:
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415