Files
nairobi/app/controllers/admin/site_customization/information_texts_controller.rb
Javi Martín c1fbcb4e0f Remove obsolete resource method in controllers
This method was used by controllers using the `Translatable` concern. We
forgot to remove it in commit 71601bd3f.
2024-11-08 15:03:51 +01:00

34 lines
911 B
Ruby

class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomization::BaseController
before_action :delete_translations, only: [:update]
def index
@tab = params[:tab] || :basic
@content = I18nContent.content_for(@tab)
end
def update
I18nContent.update(content_params, enabled_translations)
redirect_to admin_site_customization_information_texts_path,
notice: t("flash.actions.update.translation")
end
private
def content_params
params.require(:contents).values
end
def delete_translations
languages_to_delete = params[:enabled_translations].select { |_, v| v == "0" }.keys
languages_to_delete.each do |locale|
I18nContentTranslation.where(locale: locale).destroy_all
end
end
def enabled_translations
params.fetch(:enabled_translations, {}).select { |_, v| v == "1" }.keys
end
end