Sha256: 04c88b6fc7d8b0744d2372d688dbedaf8d98691112f92201ad017ed29849bf14
Contents?: true
Size: 1.35 KB
Versions: 9
Compression:
Stored size: 1.35 KB
Contents
module Logistics module Core class DeclarantsController < ApplicationController before_action :set_declarant, only: [:update] def index declarants = Declarant.all response = Mks::Common::MethodResponse.new(true, nil, declarants, nil, nil) render json: response end def create @declarant = Declarant.new(declarant_params) if @declarant.save response = Mks::Common::MethodResponse.new(true, 'Declarant saved successfully!', @declarant, nil, nil) else errors = Mks::Common::Util.error_messages @declarant, 'Declarant' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end def update if @declarant.update(declarant_params) response = Mks::Common::MethodResponse.new(true, "Declarant updated successfully!", @declarant, nil, nil) else errors = Mks::Common::Util.error_messages @declarant, "Declarant" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end private def set_declarant @declarant = Declarant.find(params[:id]) end def declarant_params params.require(:declarant).permit(:first_name, :last_name, :number) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems