Ruby on Rails: having two xmlbuilder templates per action , one for errors one for regular output
- by randombits
What's the best way to handle having two templates (or should it be one, DRY?) for xml builder templates?
I'm building a web api with Rails and wanted to see an example of how to have a view that does regular output vs one that does error output. I've been using @obj.to_xml for a while, but my requirements have changed and require me building my own error templates.
do you typically have both views in one with a condition above for errors such as
app/views/myresource/create.xml.builder
unless @myobj.errors.empty?
// xml for errors here?
end
// regular xml view