From b78b17a0e024a7ebf567355e8e57d87c0a903069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Thu, 9 Feb 2023 16:13:02 +0100 Subject: [PATCH] cc --- app/controllers/admin/university/people_controller.rb | 4 ++-- app/controllers/concerns/admin/translatable.rb | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/university/people_controller.rb b/app/controllers/admin/university/people_controller.rb index cd03b3fd9..620d359ca 100644 --- a/app/controllers/admin/university/people_controller.rb +++ b/app/controllers/admin/university/people_controller.rb @@ -24,9 +24,9 @@ class Admin::University::PeopleController < Admin::University::ApplicationContro def in_language language = Language.find_by!(iso_code: params[:lang]) translation = @person.find_or_translate!(language) - # There's an attribute accessor named "newly_translated" that we set to true - # when we just created the translation. We use it to redirect to the form instead of the show. if translation.newly_translated + # There's an attribute accessor named "newly_translated" that we set to true + # when we just created the translation. We use it to redirect to the form instead of the show. redirect_to [:edit, :admin, translation.becomes(translation.class.base_class)] else redirect_to [:admin, translation.becomes(translation.class.base_class)] diff --git a/app/controllers/concerns/admin/translatable.rb b/app/controllers/concerns/admin/translatable.rb index 7378eb5b9..6b74b8479 100644 --- a/app/controllers/concerns/admin/translatable.rb +++ b/app/controllers/concerns/admin/translatable.rb @@ -17,15 +17,13 @@ module Admin::Translatable if ['edit', 'update'].include?(action_name) # Safety net on update action if called on wrong language redirect_to [:edit, :admin, translation.becomes(translation.class.base_class)] - else + elsif translation.newly_translated # Safety net on destroy action if called on wrong language # There's an attribute accessor named "newly_translated" that we set to true # when we just created the translation. We use it to redirect to the form instead of the show. - if translation.newly_translated - redirect_to [:edit, :admin, translation.becomes(translation.class.base_class)] - else - redirect_to [:admin, translation.becomes(translation.class.base_class)] - end + redirect_to [:edit, :admin, translation.becomes(translation.class.base_class)] + else + redirect_to [:admin, translation.becomes(translation.class.base_class)] end end -- GitLab