Hi yet again! I''m currently using an erb template to generate XML for a model (say /persons.xml), because I need custom tags added to the XML I have to generate it from zero. I tried using person.to_xml but that returns a whole XML document. Is there an easier way to insert custom values in a model''s XML generation? I could redefine the to_xml method but it''d be the same work of having to include all the other values. Could I define kind of like a virtual column for the model that gets picked up by to_xml? Thanks! - Ivan V. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 26 Jun 2008, at 17:46, Ivan V. wrote:> > Hi yet again! > > I''m currently using an erb template to generate XML for a model (say > /persons.xml), because I need custom tags added to the XML I have to > generate it from zero. > > I tried using person.to_xml but that returns a whole XML document. > > Is there an easier way to insert custom values in a model''s XML > generation? I could redefine the to_xml method but it''d be the same > work > of having to include all the other values. > > Could I define kind of like a virtual column for the model that gets > picked up by to_xml? >yes. See the :only, :except and :methods options to to_xml, or the block form of to_xml Fred> Thanks! > > - Ivan V. > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 26 Jun 2008, at 17:46, Ivan V. wrote: > >> generation? I could redefine the to_xml method but it''d be the same >> work >> of having to include all the other values. >> >> Could I define kind of like a virtual column for the model that gets >> picked up by to_xml? >> > yes. See the :only, :except and :methods options to to_xml, or the > block form of to_xml > > FredDuh! I should''ve look into the to_xml documentation. Thanks a lot. Ivan V. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---