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?
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
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