Module: Kaui::ErrorHandler
- Extended by:
- ActiveSupport::Concern
- Includes:
- EngineControllerUtil
- Included in:
- EngineController
- Defined in:
- lib/kaui/error_handler.rb
Constant Summary
Constants included from EngineControllerUtil
Kaui::EngineControllerUtil::MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD
Instance Method Summary collapse
Instance Method Details
#perform_redirect_after_error(error:, error_message:, redirect: true) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kaui/error_handler.rb', line 28 def perform_redirect_after_error(error:, error_message:, redirect: true) account_id = nested_hash_value(params.permit!.to_h, :account_id) home_path = kaui_engine.home_path redirect_path = if redirect && account_id.present? kaui_engine.account_path(account_id) else home_path end redirect_path_without_query = redirect_path.to_s.split('?').first already_on_redirect_target = request.path == redirect_path_without_query already_on_home = params[:controller].to_s.ends_with?('home') && action_name == 'index' raise error if already_on_redirect_target || (redirect_path == home_path && already_on_home) flash[:error] = redirect_to redirect_path end |