Ensure all non 200 response code pages (404 and 500) - rotati/wiki GitHub Wiki
Create a errors response page
- create a controller called any thing you prefer in our case we call
errors_controller.rb
```
class ErrorsController < ApplicationController
before_action :switch_tenant
layout 'purchaser'
def not_found
render(status: 404)
end
def internal_server_error
render(status: 500)
end
end
```
- got to
routes.rb
create two routes for handling the errors
```
match "/404", :to => "errors#not_found", :via => :all
match "/500", :to => "errors#internal_server_error", :via => :all
```
* NOTE: check the environment if you want to error to run only for `production`
```
unless Rails.env.development?
match "/404", :to => "errors#not_found", :via => :all
match "/500", :to => "errors#internal_server_error", :via => :all
end
```
- last but not least goto
views
create a directory called errors
* in errors
directory, create two files
.row
.col-xs-12.content
.title.text-center
%h1 404
%h1 We've had a facelift!
.intro.text-center
%p The page you are looking for may have been removed or redirected to a new location.
.intro.text-center
%p
Visit our home page at
= succeed "." do
%a{:href => "/"}
Your Company Name
internal_server_error.haml
.row
.col-xs-12.content
.title.text-center
%h1 500
%h1 We are sorry, but something went wrong at our end!
.intro.text-center
%p
Visit our home page at
= succeed "." do
%a{:href => "/"}
Your Company Name