blob: 8e59972cb059b80e6e3ef686cea6cbce42f29e4a (
plain) (
tree)
|
|
class Pdfresource < ApplicationRecord
has_many_attached :pdfs
has_many_attached :thumbnails
has_many_attached :pdf_snapshots
belongs_to :resource_type
validates :feature_slot,
inclusion: { in: [ 1, 2, 3 ], message: "must be 1, 2, or 3" },
uniqueness: { message: "is already taken by another featured resource" },
allow_nil: true
validate :validate_pdf_count
validates :name, :thumbnails, :description, :card_description, :pdfs, :credits, presence: true
def validate_pdf_count
if pdfs.size > 10
errors.add(:pdfs, "You can upload up to 10 PDFs per resource.")
end
end
end
|