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.
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.
the resulting XML has the < and > symbols escaped out <?xml
version="1.0"
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?
the resulting XML has the < and > symbols escaped out <?xml
version="1.0"
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
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.