In my application_controller.rb
I catch all 404s with a render_404
method:
def render_404(exception)
respond_to do |format|
format.html { render template: 'errors/error_404', layout: 'layouts/application', status: 404 }
format.all { render nothing: true, status: 404 }
end
end
The second line used to work fine for all formats other than HTML, which is particularly useful when bots throw random page requests at you.
After updating from Rails 4.0.4 to 4.1.1, requests for non-HTML formats throw ActionController::UnknownFormat
errors at me, which triggers a 500 and sends me an email. I'm guessing this is due to the addition of variants, but I couldn't find exactly what's wrong in the Rails code.
Commenting out the format.html
line makes the format.all
line work. I can probably hack my render_500
method to react in a specific way when it gets a ActionController::UnknownFormat
but that's not ideal. Any idea how to fix this?