How to replace the default Rails 404 page

If you Google “The page you were looking for doesn’t exist Rails Heroku” you’ll find the StackOverflow questions from beginning developers who expect this message has something to do with the problem they’re facing. What they don’t know is that this is just the default 404 page in Rails, which they wouldn’t have encountered until deploying to Heroku (when your app runs locally, it gives you an actual error message).

image

I was convinced that the text and design on this page was due to Heroku and searched all over the site trying to find out how to change it to something more user-friendly. Eventually, I realized that both the HTML and CSS was literally a file in my app’s ‘public’ folder.

If you want your error pages to look at home on your website, all you have to do is change the code in these three files – 404.html, 422.html and 500.html.

I opted for a pun relevant to my users, who are book readers. “We seem to have lost our page. Can we start from the beginning?” along with an image of book shelves I found on Imgur.

image

What’s on your 404 page?