diff --git a/app/controllers/admin/university/people_controller.rb b/app/controllers/admin/university/people_controller.rb index cd03b3fd957fb1a8ba68fb90e5f5ddc08cfd8da1..620d359ca4109970d3e5576310fa51a8abc639e2 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 7378eb5b9514677f974813128482ca15bbabcebb..6b74b8479d2f54a2fc8bcacc5679924f968cfd70 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