I want to be able to display an HTTP 500 error with an XML builder template if the request Accept type is asking for XML. By default it displays 500.html, even if the request type is not asking for an HTML response.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do this with a custom piece of Rack middleware. Rails 2 does exactly this in
actionpack/lib/action_controller/failsafe.rb, though I’m not sure how Rails 3 is doing it. See the guide for instructions on how to do it. In your case I think you want to make your own version of that failsafe middleware, but one that checks the Accept header/url and determines the error file to use from that, then pull out the current Failsafe middleware and replace it with your version.