Sha256: acaa229016834f94dcc6a829049da15e1c4d9938a833d137b9a0f5b683a23b40
Contents?: true
Size: 1.34 KB
Versions: 9
Compression:
Stored size: 1.34 KB
Contents
module Logistics module Core class UnitTypesController < ApplicationController before_action :set_unit_type, only: [:update] def index unit_types = UnitType.all response = Mks::Common::MethodResponse.new(true, nil, unit_types, nil, nil) render json: response end def create @unit_type = UnitType.new(unit_type_params) if @unit_type.save response = Mks::Common::MethodResponse.new(true, 'Unit type saved successfully!', @unit_type, nil, nil) else errors = Mks::Common::Util.error_messages @unit_type, 'Unit type' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end def update if @unit_type.update(unit_type_params) response = Mks::Common::MethodResponse.new(true, "Unit type updated successfully!", @unit_type, nil, nil) else errors = Mks::Common::Util.error_messages @unit_type, "Unit type" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end private def set_unit_type @unit_type = UnitType.find(params[:id]) end def unit_type_params params.require(:unit_type).permit(:code, :name, :description) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems