This may be a basic question but it has been causing me some problems. I am trying to dump an ActiveRecord Object to an XML file using the to_xml function. For whatever reason, this does not work for me if I try to nest it into an element. Basically I have a hash of ActiveRecord objects that I want to iterate over, and then dump into my XML file like this:
@hash_of_activerecord.each do |key, value|
xml.object do
value.to_xml
end
end
For whatever reason this does not seem to work. What can I do to fix it? Obviously I could just print out each aspect of the object individually but that is not the best solution because I would have to remember to change what is in that loop if I later made a change to the contents of that ActiveRecord object.