5

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?

1 Answer 1

6

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.