Sha256: f2af987ab39162955f7799bbeb325087f3b870211060817c97ba6111c0d961fb

Contents?: true

Size: 970 Bytes

Versions: 1

Compression:

Stored size: 970 Bytes

Contents

module Spree
  module Admin
    class PaymentMethodTranslationsController < Spree::Admin::BaseController
      def translate
        # Need to manually update translations, otherwise Rails
        # accepts_nested_attributes_for in combination with current mobility
        # implementation has some problems with the subclasses used with
        # PaymentMethods
        payment_method = Spree::PaymentMethod.find(params[:id])

        translations_params =
          params.require(:payment_method).permit(
            [translations_attributes: [:id, :locale, :name, :description]])

        payment_method.translations.delete_all
        translations_params[:translations_attributes].each_pair do |k, value|
          payment_method.translations.create(value)
        end

        flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:payment_method))
        redirect_to spree.edit_admin_payment_method_path(payment_method)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_mobility-1.4.0 app/controllers/spree/admin/payment_method_translations_controller.rb