From e37dceb05e564b4d90b75a8c3eacff90b8ad3d14 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 15 May 2012 09:30:02 +0100 Subject: Allow themes to effect the design of error pages --- app/controllers/application_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d0cca3e4..e354b64a4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -120,6 +120,13 @@ class ApplicationController < ActionController::Base def rescue_action_in_public(exception) # Make sure expiry time for session is set (before_filters are # otherwise missed by this override) + begin + set_view_paths + rescue NameError => e + if !(e.message =~ /undefined local variable or method `set_view_paths'/) + raise + end + end session_remember_me case exception when ActiveRecord::RecordNotFound, ActionController::UnknownAction, ActionController::RoutingError -- cgit v1.2.3 From 4593cc9e546878d69f795ce75808aae60656213c Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 15 May 2012 11:21:30 +0100 Subject: Add a comment to explain why we're calling `set_view_paths` in the controller when the method doesn't exist in Alaveteli code. See [this comment](https://github.com/sebbacon/alaveteli/issues/320#issuecomment-5711523) for discussion. --- app/controllers/application_controller.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e354b64a4..47accae1c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -118,8 +118,11 @@ class ApplicationController < ActionController::Base # Override default error handler, for production sites. def rescue_action_in_public(exception) - # Make sure expiry time for session is set (before_filters are - # otherwise missed by this override) + # Call `set_view_paths` from the theme, if it exists. + # Normally, this is called by the theme itself in a + # :before_filter, but when there's an error, this doesn't + # happen. By calling it here, we can ensure error pages are + # still styled according to the theme. begin set_view_paths rescue NameError => e @@ -127,6 +130,8 @@ class ApplicationController < ActionController::Base raise end end + # Make sure expiry time for session is set (before_filters are + # otherwise missed by this override) session_remember_me case exception when ActiveRecord::RecordNotFound, ActionController::UnknownAction, ActionController::RoutingError -- cgit v1.2.3