Am 13.06.2009 um 01:36 schrieb Felix Schäfer: > Am 13.06.2009 um 01:16 schrieb Robert Walker: > >> http://api.rubyonrails.org/classes/ActiveRecord/XmlSerialization.html >> >> From the bottom of the above page... > > > Yeah, I had read that one already, and that was what I meant with a > solution for this special case: it solves the problem for to_xml, but > if I ever were to use to_yaml, I'd have to override it too, and > whatever method yields a formatted output of the model's instance. > What I'd really like is to make the virtual fact appear real. Another > quick way that came to mind would be to just add the attributes as > columns in a migration, and leave them blank, but that makes for empty > columns and seems more of a hack than a solution.
As a follow-up on this one: the (dirty) hack that consists in adding a column that basically never gets used does work, but I found a third way apart from that and tackling .to_xml. In essence, you can pass .to_xml some parameters to control the output of to_xml, notably in this case the :methods parameter, which just goes and includes the return value of said methods as attributes named after these methods in the resulting xml. While not ideal in the sense that would have like it, it seems less deep-going than defining a custom .to_xml. Regards, Felix --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

