Added pdf file upload
This commit is contained in:
@@ -2,6 +2,10 @@ class Job < ApplicationRecord
|
||||
belongs_to :operator, class_name: 'User', optional: true
|
||||
belongs_to :costumer, class_name: 'User', optional: true
|
||||
|
||||
has_one_attached :pdf
|
||||
|
||||
validates_presence_of :costumer_firstname, :costumer_lastname, :privacy_policy_accepted, :pdf
|
||||
|
||||
# NOTE: Multiple status if paing before brinting?
|
||||
enum status: {
|
||||
open: 0,
|
||||
@@ -32,4 +36,16 @@ class Job < ApplicationRecord
|
||||
def fullname
|
||||
[costumer_firstname, ' ', costumer_lastname].join
|
||||
end
|
||||
|
||||
# TODO: Implement validation
|
||||
def acceptable_pdf
|
||||
return unless pdf.attached?
|
||||
|
||||
errors.add(:main_image, 'is too big') unless main_image.blob.byte_size <= 100.megabyte
|
||||
|
||||
acceptable_types = ['application/pdf']
|
||||
return if acceptable_types.include?(main_image.content_type)
|
||||
|
||||
errors.add(:main_image, 'must be a PDF')
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user