Felix Schäfer wrote: > My problem here is that attributes the Parent has the Child doesn't > don't get included in stuff like .to_xml or even .attributes. In the > example at hand, if child has the column 'nifty' but not 'some' and > the parent has both, Child.find(0).attributes yields 'nifty' but not > 'some', same for Child.find(0).to_xml and so on. Is there a way to > tell the Child model that even if the attributes are virtual, I want > some of them to behave like real ones?
http://api.rubyonrails.org/classes/ActiveRecord/XmlSerialization.html >From the bottom of the above page... ---- You may override the to_xml method in your ActiveRecord::Base subclasses if you need to. The general form of doing this is class IHaveMyOwnXML < ActiveRecord::Base def to_xml(options = {}) options[:indent] ||= 2 xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) xml.instruct! unless options[:skip_instruct] xml.level_one do xml.tag!(:second_level, 'content') end end end ---- -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

