diff --git a/app/assets/javascripts/errors.js b/app/assets/javascripts/errors.js
new file mode 100644
index 0000000..dee720f
--- /dev/null
+++ b/app/assets/javascripts/errors.js
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index b1b2209..e46b2ee 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -7,3 +7,4 @@
/* local */
@import "variables";
@import "playtime";
+@import "error";
\ No newline at end of file
diff --git a/app/assets/stylesheets/error.scss b/app/assets/stylesheets/error.scss
new file mode 100644
index 0000000..5ed6e47
--- /dev/null
+++ b/app/assets/stylesheets/error.scss
@@ -0,0 +1,29 @@
+// Error pages css
+.error {
+ margin: 150px auto;
+ text-align: center;
+}
+
+.error-code {
+ bottom: 60%;
+ color: #2d353c;
+ font-size: 96px;
+ line-height: 100px;
+}
+
+.error-desc {
+ font-size: 12px;
+ color: #647788;
+}
+
+.m-b-10 {
+ margin-bottom: 10px!important;
+}
+
+.m-b-20 {
+ margin-bottom: 20px!important;
+}
+
+.m-t-20 {
+ margin-top: 20px!important;
+}
\ 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..42af3e2
--- /dev/null
+++ b/app/controllers/errors_controller.rb
@@ -0,0 +1,16 @@
+class ErrorsController < ApplicationController
+ before_action :skip_authorization
+ layout "error"
+
+ def not_found
+ render(:status => 404)
+ end
+
+ def internal_server_error
+ render(:status => 500)
+ end
+
+ def unprocessable_entity
+ render(:status => 422)
+ 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..d0ccc0d
--- /dev/null
+++ b/app/views/errors/internal_server_error.html.erb
@@ -0,0 +1,13 @@
+
+
+
Oops, something went wrong
+
+ The server is unavailable for the moment. We're doing everything we can to correct the problem.
+
+ Please try again later.
+
+
+ <%= link_to 'Go back to Homepage', root_path , class:"login-detail-panel-button btn" %>
+
+
+
\ 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..8a670ec
--- /dev/null
+++ b/app/views/errors/not_found.html.erb
@@ -0,0 +1,12 @@
+
+
+
We couldn't find the page
+
+ Sorry, but the page you are looking for was either not found or does not exist.
+ Try refreshing the page or click the button below to go back to the Homepage.
+
+
+ <%= link_to 'Go back to Homepage', root_path , class:"login-detail-panel-button btn" %>
+
+
+
\ No newline at end of file
diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb
new file mode 100644
index 0000000..8a2c9cd
--- /dev/null
+++ b/app/views/errors/unprocessable_entity.html.erb
@@ -0,0 +1,11 @@
+
+
+
The change you wanted was rejected
+
+ Maybe you tried to change something you didn't have access to.
+
+
+ <%= link_to 'Go back to Homepage', root_path , class:"login-detail-panel-button btn" %>
+
+
+
\ No newline at end of file
diff --git a/app/views/layouts/error.html.erb b/app/views/layouts/error.html.erb
new file mode 100644
index 0000000..fbd8f1c
--- /dev/null
+++ b/app/views/layouts/error.html.erb
@@ -0,0 +1,18 @@
+
+
+
+ Playtime
+ <%= csrf_meta_tags %>
+ <%= favicon_link_tag 'favicon.png' %>
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
+ <%= favicon_link_tag 'https://www.playtimeproject.org/wp-content/uploads/2013/03/Logo-no-words-e1363625449703.png'%>
+
+
+
+
+ <%= yield %>
+
+
+
diff --git a/config/application.rb b/config/application.rb
index 6fa4723..18b6b91 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -15,6 +15,9 @@ class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
+ # Serve error pages from the app
+ config.exceptions_app = self.routes
+
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
diff --git a/config/routes.rb b/config/routes.rb
index aab60b3..7841899 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,11 @@
# frozen_string_literal: true
Rails.application.routes.draw do
+ # Error Pages
+ get '/404', :to => 'errors#not_found'
+ get '/500', :to => 'errors#internal_server_error'
+ get '/422', :to => 'errors#unprocessable_entity'
+
# Pledges
resources :pledges, except: [:new] do
patch :claim
diff --git a/public/404.html b/public/404.html
deleted file mode 100644
index 2be3af2..0000000
--- a/public/404.html
+++ /dev/null
@@ -1,67 +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.
-
-
If you are the application owner check the logs for more information.
-
-
-
diff --git a/public/422.html b/public/422.html
deleted file mode 100644
index c08eac0..0000000
--- a/public/422.html
+++ /dev/null
@@ -1,67 +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.
-
-
If you are the application owner check the logs for more information.
-
-
-
diff --git a/public/500.html b/public/500.html
deleted file mode 100644
index 78a030a..0000000
--- a/public/500.html
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
- We're sorry, but something went wrong (500)
-
-
-
-
-
-
-
-
-
We're sorry, but something went wrong.
-
-
If you are the application owner check the logs for more information.
-
-
-
diff --git a/spec/controllers/errors_controller_spec.rb b/spec/controllers/errors_controller_spec.rb
new file mode 100644
index 0000000..8aadf97
--- /dev/null
+++ b/spec/controllers/errors_controller_spec.rb
@@ -0,0 +1,26 @@
+require 'rails_helper'
+
+RSpec.describe ErrorsController, type: :controller do
+
+ describe "GET #not_found" do
+ it "returns http success" do
+ get :not_found
+ expect(response).to have_http_status(:not_found)
+ end
+ end
+
+ describe "GET #internal_server_error" do
+ it "returns http success" do
+ get :internal_server_error
+ expect(response).to have_http_status(:internal_server_error)
+ end
+ end
+
+ describe "GET #unprocessable_entity" do
+ it "returns http success" do
+ get :unprocessable_entity
+ expect(response).to have_http_status(:unprocessable_entity)
+ end
+ end
+
+end