Best respond_to design practice

Hi All,

I am in the middle of building a web service using the standard:

# Return the appropriate response based on the type
respond_to do |format|
  format.html { render :layout => 'some layout' }
  format.xml  { render :xml => @data.to_xml }
end

My question is the following possible…

I’d like to insert some custom XML tags before all object.to_xml data
which are returned by the web service. For example:

- contains a numeric result code
<result_msg></result_msg> - contains result string
followed by the object to XML data

Is this possible?

Also, can you filter out specific fields from the response XML?

Thanks,
Rick

From the API,
http://api.rubyonrails.org/classes/ActiveRecord/XmlSerialization.html

“Builds an XML document to represent the model. Some configuration is
availble through options, however more complicated cases should use
override ActiveRecord‘s to_xml.”

This should get you started.

best.
mike