Imagine a case: you want to render Not found page somewhere from the controller.
You could raise
ActionController::RoutingError, but none of them are related to your error case: it’s neither ActiveRecord nor Routing error.
We usually use
head :not_found in such cases.
The current issue with
head :not_found is that in development it renders a blank page and in production it renders fancy
public/404.html. I’m familiar with this behaviour, but it may be quite struggling for developers who are new to Rails.
During the code review, I’ve noticed that developers explicitly create a new
render_not_found method, where they read
public/404.html and render the contests because they see that
head :not_found results to a blank page (and they don’t know that it’s in development only!)
I propose to change the behaviour of
ActionDispatch::PublicExceptions to catch display error pages that were trigger by developer (like
head :not_found was in my example)