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.9.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.8.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.8.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.7.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.7.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.7.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.6.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.6.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.6.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.5.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.5.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.4.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.4.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.4.0 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.3.5 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.3.4 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.3.3 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.3.2 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.3.1 app/controllers/concerns/backend/translatable_controller.rb
udongo-7.2.1 app/controllers/concerns/backend/translatable_controller.rb