Only problem is, as the site grew in popularity, we would get errors of bad routes, like the Google Accelerator trying to fetch URLs that don’t exist. This usually fails with a 500 application error, so we’d get a lot of exceptions from “bots” like this for nothing. If a URL that does not exist is accessed, one would typically think that “404 not found” is a better choice of response. I think so too. Here’s what you do to make it return 404 instead of 500.
Put this in your application.rb (ApplicationController):
That’s it, now bad routes will return 404 errors.
You can optionally change the case statement to a simple if/else, but as a case statement you have the option to put in other exceptions and perform additional processing if needed.