I have an exception ActionController::RoutingError
when the user tries to access a non existing route. How can I redirect the user to the 404.html page or render an error on that page?
e.g: when I try to access https://github.com/someuser I get a 404 page on that URL.
I've tried this in application controller with no success:
rescue_from ActionController::RoutingError do |exception|
render '/public/404.html'
end
This is a known problem. You should have a look at the comments posted there, especially this one by Jose Valim.
Edit: This seems to be a better solution, and compatible with other Rack middlewares.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With