Sha256: f4b8b5d341a66e5d9352340d3acd7e246bad17d500f0966ea5b247892b011f71

Contents?: true

Size: 974 Bytes

Versions: 65

Compression:

Stored size: 974 Bytes

Contents

module Concerns
  module Backend
    module TranslatableController
      extend ActiveSupport::Concern

      included do
        before_action :find_models, only: [:edit_translation, :update_translation]
        helper_method :translatable_path
      end

      def update_translation
        if @translation.save(params[model_name])
          redirect_to translatable_path, notice: t('b.msg.changes_saved')
        else
          render :edit_translation
        end
      end

      private

      def find_models
        @model ||= find_model
        @translation = translation_form
      end

      def model_name
        @model.class.to_s.underscore.gsub('_decorator', '')
      end

      def set_translatable_path(path)
        @translatable_path ||= path
      end

      def translatable_path
        method = "edit_translation_backend_#{model_name}_path"
        @translatable_path || send(method, @model, params[:translation_locale])
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
udongo-7.2.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.1.3 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.1.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.1.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.1.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.0.4 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.0.3 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.0.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.0.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.0.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.6.3 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.6.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.6.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.6.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.5.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.5.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.5.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.4.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.4.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-6.3.2 app/controllers/concerns/backend/translatable_controller.rb