Sha256: 56b30ff83a51a5e5af64f0a1fdcb0b78a1a8432d4f3614cbfc63569f26333ea2

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

module Lit
  class LocalizationsController < ::Lit::ApplicationController
    before_filter :find_localization_key
    before_filter :find_localization

    def edit
      @localization.translated_value = @localization.get_value
      respond_to :js
    end

    def update
      if @localization.update_attributes(clear_params)
        Lit.init.cache.update_cache @localization.full_key, @localization.get_value
      end
      @localization.reload
      respond_to :js
    end

    def previous_versions
      @versions = @localization.versions.order('created_at DESC')
      respond_to :js
    end

    private
      def find_localization_key
        @localization_key = Lit::LocalizationKey.find(params[:localization_key_id])
      end

      def find_localization
        @localization = @localization_key.localizations.find(params[:id])
      end

      def clear_params
        if defined?(::ActionController::StrongParameters)
          # allow translated_value to be an array
          if @localization.value.is_a?(Array)
            params.require(:localization).permit(:locale_id, :translated_value => [])
          else
            params.require(:localization).permit(:locale_id, :translated_value)
          end
        else
          params[:localization].is_a?(Hash) ? params[:localization].slice(:translated_value, :locale_id) : {}
        end
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lit-0.2.4 app/controllers/lit/localizations_controller.rb
lit-0.2.3 app/controllers/lit/localizations_controller.rb