Skip to content
Snippets Groups Projects
Unverified Commit b78b17a0 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

cc

parent 51bf85a6
No related branches found
No related tags found
No related merge requests found
......@@ -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)]
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment