Sha256: a779870f6980f54ec2fa7b64688266875867c5eded68ed602a1fec58a25f9de8

Contents?: true

Size: 772 Bytes

Versions: 22

Compression:

Stored size: 772 Bytes

Contents

class Apiv1::Translations::UpdateController < Admin::BaseController

  def update
    if _update_successful?
      render json: { translation: _translation_hash }
    else
      render json: { translation: _failure_hash }, status: :expectation_failed
    end
  end

  private
  def _update_successful?
    _translation.valid? && _translation.save!
  end

  def _translation
    _raw_translation.tap { |t| t.assign_attributes _translation_params }
  end

  def _raw_translation
    @translation ||= Apiv1::Translation.find params[:id]
  end

  def _translation_params
    params.require(:translation).permit(:key, :locale, :translated_text, :value)
  end

  def _translation_hash
    _translation.attributes
  end

  def _failure_hash
    _translation.errors.to_h
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cloudrider-0.3.23 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.3.22 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.3.21 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.3.20 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.3.0 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.18 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.15 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.14 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.12 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.11 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.10 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.9 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.8 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.7 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.6 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.5 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.4 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.3 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.2 generica/app/controllers/apiv1/translations/update_controller.rb
cloudrider-0.2.1 generica/app/controllers/apiv1/translations/update_controller.rb