views:

37

answers:

1

I'm creating a simple XML API in Rails, and currently, when there's an error, it renders the standard HTML error pages in public/, e.g. error in /tests.xml causes rendering of public/404.html.

Is there a way to make it render public/404.xml instead?

A: 

You probably want to take advantage of the fact that the render method can render custom XML and an HTTP status, like so:

# Renders '<error>Not found</error>'
render :xml => { :error => 'Not found' }, :status => 404
John Topley