diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 364c77d..b24eb34 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -895,3 +895,15 @@ form .checkbox input[type="checkbox"] { } } } + +.errors { + padding: 3em; + + h3 { + margin-left: auto; + margin-right: auto; + max-width: 75%; + padding: 1em; + line-height: 1.6em; + } +} \ No newline at end of file diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 0000000..479fe79 --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,9 @@ +class ErrorsController < ApplicationController + def not_found + render status: 404 + end + + def internal_server_error + render status: 500 + end +end diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb new file mode 100644 index 0000000..80e296e --- /dev/null +++ b/app/views/errors/internal_server_error.html.erb @@ -0,0 +1,8 @@ +
+

Internal server error

+

+ We're sorry, there seems to be an error with this request. + A notification has automatically been sent to us, and we will resolve this as soon as possible. +

+

<%= link_to 'Home', root_path, class: 'btn btn-default' %>

+
\ No newline at end of file diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb new file mode 100644 index 0000000..1c75680 --- /dev/null +++ b/app/views/errors/not_found.html.erb @@ -0,0 +1,8 @@ +
+

Not found

+

+ The page you were looking for doesn't exist. + You may have mistyped the address or the page may have moved. +

+

<%= link_to 'Home', root_path, class: 'btn btn-default' %>

+
\ No newline at end of file diff --git a/config/application.rb b/config/application.rb index 0617d3e..97613f1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,5 +25,8 @@ module Timeoverflow # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true + + # This tells Rails to serve error pages from the app itself, rather than using static error pages in public/ + config.exceptions_app = self.routes end end diff --git a/config/routes.rb b/config/routes.rb index 409c521..480f87f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,4 +78,6 @@ Rails.application.routes.draw do end end + match '/404', to: 'errors#not_found', via: :all + match '/500', to: 'errors#internal_server_error', via: :all end diff --git a/public/404.html b/public/404.html deleted file mode 100644 index 9a48320..0000000 --- a/public/404.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - -
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
- - diff --git a/public/422.html b/public/422.html deleted file mode 100644 index 83660ab..0000000 --- a/public/422.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - -
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
- - diff --git a/public/500.html b/public/500.html deleted file mode 100644 index f3648a0..0000000 --- a/public/500.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - -
-

We're sorry, but something went wrong.

-
- -