I have an exception ActionController::RoutingError
when the us开发者_运维百科er 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.
精彩评论