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 --- config/application.rb | 2 ++ config/routes.rb | 3 +++ 2 files changed, 5 insertions(+) (limited to 'config') 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 From 97e30cc136a72092abba19f1b601ad9d5ebd5257 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 5 May 2014 12:29:21 +0200 Subject: i18n for error pages --- config/locales/en.yml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'config') diff --git a/config/locales/en.yml b/config/locales/en.yml index cebf075..899d659 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,10 +1,19 @@ en: + home: Home privacy_policy: Privacy Policy terms_of_service: Terms of Service pricing: Pricing about: About Us contact: Contact + + not_found_title: Page not found. + not_found_subtitle: "The page you were looking for doesn't exist." + not_found_lead: "You may have mistyped the address or the page may have moved." + server_error_title: Ouch! + server_error_subtitle: We ran into a server error. + server_error_lead: The problem has been logged and we will look into it. no_such_thing: "No such %{thing}." + thing_was_successfully_created: "%{thing} was successfully created." create_thing: "Create %{thing}" -- cgit v1.2.3 From b298cea527f74f682d24defee360e0f45f47d125 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 6 May 2014 09:50:46 +0200 Subject: little bit of documentation --- config/application.rb | 1 + config/routes.rb | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'config') diff --git a/config/application.rb b/config/application.rb index 1077198..8555f48 100644 --- a/config/application.rb +++ b/config/application.rb @@ -92,6 +92,7 @@ module LeapWeb ## config.paths['app/views'].unshift "config/customization/views" + # handle http errors ourselves config.exceptions_app = self.routes end end diff --git a/config/routes.rb b/config/routes.rb index f92c704..9e0b72d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,10 @@ LeapWeb::Application.routes.draw do root :to => "home#index" get '(:locale)' => 'home#index', :locale => MATCH_LOCALE, :as => 'home' + # + # HTTP Error Handling + # instead of the default error pages use the errors controller and views + # match '/404' => 'errors#not_found' match '/500' => 'errors#server_error' -- cgit v1.2.3