In mine, application_controller.rbI will catch all 404 using the method render_404:
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 is used to work perfectly for all formats other than HTML, which is especially useful when bots throw random page requests at you.
After upgrading from Rails 4.0.4 to 4.1.1, requests for non-HTML formats change errors for me ActionController::UnknownFormat, which trigger 500 and send me an email. I assume this is due to the addition of options, but I could not find exactly what was wrong in the Rails code.
Commenting out a line format.html, the line format.allworks. I can probably hack a method render_500to react in a certain way when it receives ActionController::UnknownFormat, but that is not ideal. Any idea how to fix this?
source
share