Forum: Ruby on Rails inconsistency in calling to_xml on STI returning <record>

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Zhao Lu (Guest)
on 2008-10-19 23:48
(Received via mailing list)

When calling to_xml on STI that returns heterogeneous type of records,
each record is contained in <record> node.
For example, if I have Account with subclasses EmailAccount and
PhoneAccount, Account.find(:all).to_xml gives me:
   <emailaddress1 ...>

When calling to_xml on homogeneous type of records, each record is
contained in the node with the type.
For example, Account.find(:all, :conditions=>{:type => 'PhoneAccount'})

I feel this makes writing test and client-side parsing difficult.  I
did some search and didn't find anything solutions (except a trac
ticket opened over a year ago with status open).  I also feel this is
probably a often-encountered issue and have some
pragmatic solution.  Any suggestion is appreciated.


This topic is locked and can not be replied to.