Sha256: 0cdbac16cf9f826b494be9eb90ae4eee2faaf9912cb1fa3af369a8dacac40902

Contents?: true

Size: 679 Bytes

Versions: 22

Compression:

Stored size: 679 Bytes

Contents

class Apiv1::Translations::CreateController < Admin::BaseController

  def create
    if _save_successful?
      _translation.save!
      render json: { translation: _translation_hash }
    else
      render json: { translation: _failure_hash }, status: :expectation_failed
    end
  end

  private
  def _save_successful?
    _translation.valid? 
  end

  def _translation
    @translation ||= Apiv1::Translation.new _translation_params
  end

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

  def _translation_hash
    _translation.to_ember_hash
  end

  def _failure_hash
    _translation.errors.to_h
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cloudrider-0.2.0 generica/app/controllers/apiv1/translations/create_controller.rb
cloudrider-0.1.3 generica/app/controllers/apiv1/translations/create_controller.rb