module Logistics module Core class TwentyFeetEquivalenceRatiosController < ApplicationController before_action :set_twenty_feet_equivalence_ratio, only: [:update] # GET /chargeable_services # GET /chargeable_services.json def index twenty_feet_equivalence_ratio = [] twenty_feet_equivalences = TwentyFeetEquivalenceRatio.all twenty_feet_equivalences.each{ |tfe| twenty_feet_equivalence_ratio.push({:id => tfe.id, :container_size_name => tfe.container_size.name, :container_size_id => tfe.container_size_id, :ratio => tfe.ratio}) } @response = Mks::Common::MethodResponse.new(true, nil, twenty_feet_equivalence_ratio, nil, nil) render json: @response end # POST /chargeable_services # POST /chargeable_services.json def create twenty_feet_equivalence_ratio = TwentyFeetEquivalenceRatio.new(twenty_feet_equivalence_ratio_parms) if twenty_feet_equivalence_ratio.valid? twenty_feet_equivalence_ratio.save @response = Mks::Common::MethodResponse.new(true, 'Equivalence ratio saved successfully !', nil, nil) render json: @response else errors = Mks::Common::Util.error_messages(twenty_feet_equivalence_ratio, 'TEU') response = Mks::Common::MethodResponse.new(false,nil,nil,errors,nil) render json: response end #end #end end # PATCH/PUT /chargeable_services/1 # PATCH/PUT /chargeable_services/1.json def update @twenty_feet_equivalence_ratio.update_attributes(twenty_feet_equivalence_ratio_parms) if @twenty_feet_equivalence_ratio.save @response = Mks::Common::MethodResponse.new(true, 'Equivalence ratio update successfully !', nil, nil, nil) render json: @response else errors = Mks::Common::Util.error_messages(@twenty_feet_equivalence_ratio, 'TEU') 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_twenty_feet_equivalence_ratio @twenty_feet_equivalence_ratio = TwentyFeetEquivalenceRatio.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def twenty_feet_equivalence_ratio_parms params.require(:twenty_feet_equivalence_ratio).permit(:container_size_id, :ratio) end end end end