Skip to content

Commit 41971eb

Browse files
Sophie HebdidgeSophie Hebdidge
Sophie Hebdidge
authored and
Sophie Hebdidge
committedJul 25, 2019
Generated 403, 404, 500 pages
1 parent f528b87 commit 41971eb

File tree

8 files changed

+25
-133
lines changed

8 files changed

+25
-133
lines changed
 

‎app/controllers/errors_controller.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class ErrorsController < ApplicationController
2+
def not_found
3+
render(:status => 404)
4+
end
5+
6+
def internal_server_error
7+
render(:status => 500)
8+
end
9+
10+
def forbidden
11+
render(:status => 403)
12+
end
13+
end

‎app/views/errors/forbidden.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Errors#forbidden</h1>
2+
<p>Find me in app/views/errors/forbidden.html.erb</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Errors#internal_server_error</h1>
2+
<p>Find me in app/views/errors/internal_server_error.html.erb</p>

‎app/views/errors/not_found.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Errors#not_found</h1>
2+
<p>Find me in app/views/errors/not_found.html.erb</p>

‎config/application.rb

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module SoulMedicine
2121
class Application < Rails::Application
2222
# Initialize configuration defaults for originally generated Rails version.
2323
config.load_defaults 5.2
24+
config.exceptions_app = self.routes
2425

2526
# Settings in config/environments/* take precedence over those specified here.
2627
# Application configuration can go into files in config/initializers

‎config/routes.rb

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
require 'sidekiq/web'
44

55
Rails.application.routes.draw do
6+
7+
match "/404", :to => "errors#not_found", :via => :all
8+
match "/500", :to => "errors#internal_server_error", :via => :all
9+
match "/403", :to => "errors#forbidden", :via => :all
10+
611
scope '(:locale)', locale: /#{LocalesService.enabled.join("|")}/ do
712
resources :subscriptions, only: [:index]
813

‎public/404.html

-67
This file was deleted.

‎public/500.html

-66
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.