Custom Rails error pages

Jason Gong
Oct 14, 2021

Heres the one-minute walkthrough on how to create custom error pages in Ruby on Rails.

Let’s go!

  • Delete the ones that come with Rails in public/STATUS_CODE.html
  • Add the following to config/application.rb which changes the setting s to allow you to make your custom error pages
config.exceptions_app = self.routes
  • Create a controller with actions for your error pages
rails g controller errors internal_server_error not_found
  • Add routes for those pages

Add your views such as app/views/errors/internal_server_error.html.erb and you are done. Thanks for reading!

--

--