Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RoutingError Page 404

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
like image 428
donald Avatar asked Jan 09 '11 13:01

donald


1 Answers

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.

like image 120
Dogbert Avatar answered Sep 21 '22 15:09

Dogbert