module Logistics module Core class OperationDocument < ApplicationRecord mount_base64_uploader :file, DocumentUploader belongs_to :operation belongs_to :user, class_name: 'Mks::Auth::User', optional: true belongs_to :acceptor, class_name: 'Mks::Auth::User', optional: true scope :accepted, -> { where(:accepted => true) } scope :remaining, -> { where(:accepted => false) } validates :document, :original, :copy, :certified, :operation, presence: true def user_name self.user&.first_name.to_s + ' ' + self.user&.last_name.to_s end def acceptor_name self.acceptor&.first_name.to_s + ' ' + self.acceptor&.last_name.to_s end end end end