The doc's give an example of entirely overwriting the output. All I
really wanna do is append another tag. I've tried using various
combinations of super, but super is returning a string. Is it possible
then, at least to get an example of how to override xml using super,
and appending a tag? I've been working on this for the past 3 hrs. Any
help would be greatly appreciated.

--matt

On Feb 26, 6:00 pm, Frederick Cheung <[email protected]>
wrote:
> On 26 Feb 2009, at 10:37, MattFS218 wrote:
>
>
>
> > is it possible to get a quick example of how to override .to_xml?, and
> > maybe add a little bit of markup?
>
> THere's an example in the documentation for to_xml.
>
> Fred
>
> > On Feb 26, 5:16 pm, Frederick Cheung <[email protected]>
> > wrote:
> >> On Feb 26, 10:08 am, MattFS218 <[email protected]> wrote:
>
> >>> Hey Fred,
>
> >>> Thanks for the rapid response.
>
> >>> But when I
>
> >>> format.fxml  { render :fxml => @contacts.to_fxml(:methods=>
> >>> [:my_action] ) }
>
> >>> and
>
> >>> def my_action()
> >>>   return self.kvs.to_xml
> >>> end
>
> >>> the resulting XML has the < and > symbols escaped out &lt;?xml
> >>> version=&quot;1.0&quot;
>
> >> Oh I get you.
>
> >>> Unless I'm mistaken, but associations are per Object, correct? Not  
> >>> per
> >>> instance. the Kvs i'm trying to output vary per instance. Any other
> >>> recommendations?
>
> >> You can have interpolated conditions on an association (but this does
> >> rely on you being able to express your conditions in sql, prevents
> >> eager loading etc...). Another way is a custom to_xml method on your
> >> model, you'll get a Builder::XmlMarkup object given to you on which
> >> you can generate any xml you want
>
> >> Fred
>
> >>> --matt
>
> >>> On Feb 26, 4:45 pm, Frederick Cheung <[email protected]>
> >>> wrote:
>
> >>>> On Feb 26, 9:28 am, MattFS218 <[email protected]> wrote:
>
> >>>>> I have a Contacts controller, that I'm using to output contacts  
> >>>>> when
> >>>>> an index is called, but the XML that I will output for each  
> >>>>> contact
> >>>>> varies. I'm not having any success using :proc or :method
>
> >>>>> :method could work, but the string my method returns, escapes  
> >>>>> the <>
> >>>>> characters I'm using trying to "fake" XML mark-up.
>
> >>>>> Basically, each contact has many Kvs, and I only want to :include
> >>>>> output some KV (not all) for each contact. I can :include kvs  
> >>>>> but that
> >>>>> will include ALL. I cannot used proc, because there's no way for  
> >>>>> proc
> >>>>> to "know" which individual contact it's being run for.
>
> >>>> It seems like the easiest way would be a method that calls to_xml  
> >>>> on
> >>>> those kvs you want included. Not sure what you meant about fake xml
> >>>> mark-up in your comment above. Another way might be to :include an
> >>>> association whose conditions restrict it to those Kvs you are
> >>>> interested in.
>
> >>>> Fred
>
> >>>> Fred
>
> >>>>> Can anyone recommend an easy way around this?
>
> >>>>> --matt
> > >
>
>
>  smime.p7s
> 3KViewDownload

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to