# config/routes.rb
match '/404', via: :all, to: 'errors#not_found'
match '/422', via: :all, to: 'errors#unprocessable_entity'
match '/500', via: :all, to: 'errors#server_error'
# app/controllers/errors_controller.rb
class ErrorsController < ActionController::Base
layout 'error'
def not_found
render status: :not_found
end
def unprocessable_entity
render status: :unprocessable_entity
end
def server_error
render status: :server_error
end
end