Sha256: 0f34b1297ee7ad969df98daf27dab9d319972853e020677801d6c178bc2841ad
Contents?: true
Size: 1.94 KB
Versions: 9
Compression:
Stored size: 1.94 KB
Contents
module Logistics module Core class CommonDocumentsController < ApplicationController before_action :set_common_document, only: [:update] def index common_documents = CommonDocument.includes(:document_type) data = ApplicationRecord.as_json(common_documents) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end def filter_by_operation common_documents = CommonDocument.includes(:document_type) .where(:operation_id => params[:id]) data = ApplicationRecord.as_json(common_documents) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end def create @common_document = CommonDocument.new(common_document_params) if @common_document.save response = Mks::Common::MethodResponse.new(true, 'Common document saved successfully!', @common_document, nil, nil) else errors = Mks::Common::Util.error_messages @common_document, 'Common document' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end def update if @common_document.update(common_document_params) response = Mks::Common::MethodResponse.new(true, "Common document updated successfully!", @common_document, nil, nil) else errors = Mks::Common::Util.error_messages @common_document, "Common document" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end private def set_common_document @common_document = CommonDocument.find(params[:id]) end def common_document_params params.require(:common_document).permit(:document_type_id, :original, :copy, :certified, :is_mandatory, :is_endorsed) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems