I am reading RESTful Web Services, where it is advised as a good
practice to connect resources.
Is there a way to include article urls in @articles.to_xml ?
– fxn
I am reading RESTful Web Services, where it is advised as a good
practice to connect resources.
Is there a way to include article urls in @articles.to_xml ?
– fxn
On Jan 10, 2008, at 6:21 PM, Damaris F. wrote:
- Calling any Proc‘s on the object(s), uinge :procs. The Proc‘s are
passed a modified version of the options hash that was given to
to_xml.proc = Proc.new { |options| options[:builder].tag!(‘abc’, ‘def’) }
firm.to_xml :procs => [ proc ]
… normal attributes as shown above …
def
Thank you!
I wondered though whether there was a builtin way in AR::Base#to_xml
to generate something like this:
AGH877
234.45
...
AFAIK you have to code that customization yourself. (Of course a model
does not know it has a URL so that’s fine.)
– fxn
As far as I know, simple ways to do it are (from the Rdoc
documentation):
Including any methods on the object(s) being called, using :methods:
firm.to_xml :methods => [ :calculated_earnings, :real_earnings ]
100000000000000000
5
Calling any Proc‘s on the object(s), uinge :procs. The Proc‘s are
passed a modified version of the options hash that was given to to_xml.
proc = Proc.new { |options| options[:builder].tag!(‘abc’, ‘def’) }
firm.to_xml :procs => [ proc ]
def
Xavier N. wrote:
I am reading RESTful Web Services, where it is advised as a good
practice to connect resources.Is there a way to include article urls in @articles.to_xml ?
– fxn
I wondered though whether there was a builtin way in AR::Base#to_xml
to generate something like this:AGH877234.45 ...
standard rails restful stuff uses a predictable URL scheme, so this
isn’t really needed. Also, routing uses the current request context,
and that’d have to be passed into #to_xml somehow. You could do that
now using the :procs option.
–
Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com
Ah, yes, I have right now this same problem. I’m afraid the only way to
do it is creating your own RXML template 
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs