I've been playing around with rail's to_xml, trying to create a really simple rest interface for a project i'm working on.
So far, i've come up with
cards = Card.all(:conditions => {:racedate => Date.today.to_s})
render :xml => cards.to_xml(:include => {:races => { :only => [:id, :number, :race_time, :name] } }, :skip_types => true, :root => "cards")
in my controller.
This produces some xml.
<card>
<country-code>USA</country-code>
<id>55</id>
<name>Vernon Downs</name>
<races>
<race>
<id>355</id>
<name/>
<number>1</number>
<race-time/>
</race>
</races>
</card>
What i'd really like is to use xml attributes rather than child nodes, so it would be
<card country-code="USA" id=55 name="Vernon Downs"/>
etc.
I've poured over the to_xml api docs but can't seem to find any way of doing this? Do i need to create an xml template and render that way?
Thanks