Sha256: 4a0c7455ad198c0c4c3a4e174fbdd9a5182017941798a3ccb94674a7caca3515
Contents?: true
Size: 1.9 KB
Versions: 9
Compression:
Stored size: 1.9 KB
Contents
module Logistics module Core class CarrierTypesController < ApplicationController before_action :set_carrier_type, only: [:update] def index @carrier_types = CarrierType.all carrier_type_array =[] @carrier_types.each { |ct| carrier_type_array.push({:id => ct.id, :code => ct.code, :name => ct.name, :description => ct.description }) } @response = Mks::Common::MethodResponse.new(true, nil, carrier_type_array, nil, nil) render json: @response end def create @carrier_type = CarrierType.new(carrier_type_params) if @carrier_type.valid? @carrier_type.save @response = Mks::Common::MethodResponse.new(true, 'Carrier type saved successfully !',nil,nil,nil); render json: @response else errors = Mks::Common::Util.error_messages @carrier_type, 'CarrierType' @response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) render json: @response end end def update if @carrier_type.update_attributes(carrier_type_params) @carrier_type.save @response = Mks::Common::MethodResponse.new(true, 'Carrier type updated successfully !', nil, nil, nil) render json: @response else errors = Mks::Common::Util.error_messages @carrier_type, 'CarrierType' @response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) render json: @response end end private # Use callbacks to share common setup or constraints between actions. def set_carrier_type @carrier_type = CarrierType.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def carrier_type_params params.require(:carrier_type).permit(:code, :name, :description) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems