aboutsummaryrefslogblamecommitdiffstats
path: root/app/models/pdfresource.rb
blob: 86e600c7a82b3ba5a1bee32ead9f0b03db2be949 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                                     
                                  


                                                                                                                         
                              

                                                                                                





                                                                     
   
class Pdfresource < ApplicationRecord
  has_many_attached :pdfs
  has_many_attached :thumbnails
  has_many_attached :pdf_snapshots
  validates :feature_slot,
            numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 3, allow_nil: true },
            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