Class: Document::Base

Inherits:
Kuppayam::ApplicationRecord
  • Object
show all
Defined in:
app/models/document/base.rb

Direct Known Subclasses

ImportDataFile, ImportReportFile

Constant Summary collapse

UPLOAD_LIMIT =

Constants

5242880
INSTRUCTIONS =

this is in bytes which is equivalent to 5 megabytes

[
  "<Override this instructions in your document class>"
]

Instance Method Summary collapse

Instance Method Details

#check_file_sizeObject


Instance Methods



31
32
33
34
35
# File 'app/models/document/base.rb', line 31

def check_file_size
  if document && document.file && document.file.size.to_f > self.class::UPLOAD_LIMIT
    errors.add(:document, "You cannot upload a document greater than #{Filesize.from(self.class::UPLOAD_LIMIT.to_s+ " b").pretty}")
  end
end

#display_nameObject



37
38
39
# File 'app/models/document/base.rb', line 37

def display_name
  "#{id} - #{self.class.name.split('::').last.titleize}"
end