From c80984888c7eb8d726c37882750c58e0ab454a0a Mon Sep 17 00:00:00 2001 From: f Date: Wed, 10 Apr 2024 15:16:09 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20recordar=20la=20ubicaci=C3=B3n=20#15188?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2746ab10..617ce665 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? before_action :notify_unconfirmed_email, unless: :devise_controller? around_action :set_locale + after_action :store_location! rescue_from Pundit::NilPolicyError, with: :page_not_found rescue_from ActionController::RoutingError, with: :page_not_found @@ -115,6 +116,16 @@ class ApplicationController < ActionController::Base def after_sign_in_path_for(resource) session[:locale] = nil - sites_path + super + end + + # Guardar la ubicación para que devise redirija a donde íbamos, a + # menos que estemos recibiendo información o intentando ingresar. + def store_location! + return if request.xhr? + return unless request.request_method_symbol == :GET + return if devise_controller? && !is_a?(Devise::RegistrationsController) && params[:action] != 'edit' + + session[:usuarie_return_to] = request.fullpath end end