> So do I use a render partial collection wrapping it in another call to
> render that adds the <users></users> tags or is there a cleaner
> approach? I am doing this all over the place and would rather not
> have a bunch of 3 line templates scattered everywhere. I''m
curious
> how the backpack xml api renders things as it has very similar needs
> to mine.
I use Builder in Backpack wrapped behind an XmlFormatter service
class. So you have a call like XmlFormatter.format(users), which
return the xml snippet. You could also place this stuff inside a class
method on the User, if you feel its an integrate part of the User (I
usually wouldn''t).
Example:
xml.users do
for user in users
xml.user("id" => user.id) { xml.name(user.name) }
end
end
--
David Heinemeier Hansson
http://www.loudthinking.com -- Broadcasting Brain
http://www.basecamphq.com -- Online project management
http://www.backpackit.com -- Personal information manager
http://www.rubyonrails.com -- Web-application framework