Ruby on Rails: having two xmlbuilder templates per action , one for errors one for regular output

Posted by randombits on Stack Overflow See other posts from Stack Overflow or by randombits
Published on 2010-04-22T00:55:15Z Indexed on 2010/04/23 0:33 UTC
Read the original article Hit count: 656

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rest