I have started using xml builder templates for most of my model. I need to find a generic way to build XML outside of a render which uses the .xml.builder template instead of the generic .to_xml method provided in the model
I gather that I will have to override the default to_xml (or add a to_my_xml), but I am unable to see how to get XMLBuilder to use my .builder files.
Any ideas?
Add a respond_to
block in your controller so that the appropriate template is rendered according to the requested format. For example:
def show
...
respond_to do |format|
format.html # renders show.html.erb
format.xml # renders show.xml.builder
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With