From 89e9154499f67fd8c63e1098b3e50b317c690dd0 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 5 May 2014 12:22:52 +0200 Subject: custom error pages for 404 and 500 errors --- app/controllers/errors_controller.rb | 9 +++++++++ app/views/errors/not_found.html.haml | 7 +++++++ app/views/errors/server_error.html.haml | 7 +++++++ config/application.rb | 2 ++ config/routes.rb | 3 +++ 5 files changed, 28 insertions(+) create mode 100644 app/controllers/errors_controller.rb create mode 100644 app/views/errors/not_found.html.haml create mode 100644 app/views/errors/server_error.html.haml diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 0000000..bf9329c --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,9 @@ +class ErrorsController < ApplicationController + + def not_found + end + + def server_error + end + +end diff --git a/app/views/errors/not_found.html.haml b/app/views/errors/not_found.html.haml new file mode 100644 index 0000000..22b6a55 --- /dev/null +++ b/app/views/errors/not_found.html.haml @@ -0,0 +1,7 @@ +.hero-unit + %h1 Page not found. + %h2 The page you were looking for doesn't exist. + %p.lead You may have mistyped the address or the page may have moved. + %a.btn.btn-primary.btn-large{href:'/'} + %i.icon-home.icon-white + Home diff --git a/app/views/errors/server_error.html.haml b/app/views/errors/server_error.html.haml new file mode 100644 index 0000000..173cdad --- /dev/null +++ b/app/views/errors/server_error.html.haml @@ -0,0 +1,7 @@ +.hero-unit + %h1 Ouch! + %h2 We ran into a server error. + %p.lead The problem has been logged and we will look into it. + %a.btn.btn-primary.btn-large{href:'/'} + %i.icon-home.icon-white + Home diff --git a/config/application.rb b/config/application.rb index 2c9c55a..1077198 100644 --- a/config/application.rb +++ b/config/application.rb @@ -91,5 +91,7 @@ module LeapWeb ## see initializers/customization.rb ## config.paths['app/views'].unshift "config/customization/views" + + config.exceptions_app = self.routes end end diff --git a/config/routes.rb b/config/routes.rb index 745b97d..f92c704 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,9 @@ LeapWeb::Application.routes.draw do root :to => "home#index" get '(:locale)' => 'home#index', :locale => MATCH_LOCALE, :as => 'home' + match '/404' => 'errors#not_found' + match '/500' => 'errors#server_error' + scope "(:locale)", :locale => MATCH_LOCALE, :controller => 'pages', :action => 'show' do get 'privacy-policy', :as => 'privacy_policy' get 'terms-of-service', :as => 'terms_of_service' -- cgit v1.2.3