require_dependency "application_controller" module Logistics module Core class StandardRemarksController < ApplicationController before_action :set_standard_remark, only: [:update] def index standard_remarks = StandardRemark.all render json: Mks::Common::MethodResponse.new(true, nil, standard_remarks, nil, nil) end def create standard_remark = StandardRemark.new(standard_remark_params) if standard_remark.save res = Mks::Common::MethodResponse.new(true, 'Remark added successfully !', nil, nil, nil) else errors = Mks::Common::Util.error_messages('Standard Remark', standard_remark) res = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: res end def update if @standard_remark.update(standard_remark_params) res = Mks::Common::MethodResponse.new(true, 'Remark updated successfully !', nil, nil, nil) else errors = Mks::Common::Util.error_messages(@standard_remark, 'Standard Remark') res = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: res end private def standard_remark_params params.require(:standard_remark).permit(:id, :code, :description) end def set_standard_remark @standard_remark = StandardRemark.find(params[:id]) end end end end