diff options
author | Matthew Lemon <y@yulqen.org> | 2024-11-13 20:22:52 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-11-13 20:22:52 +0000 |
commit | 9f6bca8186fb29eb26e9e40670013f6948e1efc3 (patch) | |
tree | bfae43dbc4fcb52ff6ce74f7cd32c0203adf042f /app/models | |
parent | 25afd4b7ef65ea7164b43d0599d901aedf252536 (diff) |
Rough rendition of pdf snapshotter works
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/pdfresource.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/pdfresource.rb b/app/models/pdfresource.rb index 6614f66..110a3c7 100644 --- a/app/models/pdfresource.rb +++ b/app/models/pdfresource.rb @@ -1,7 +1,16 @@ 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, 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 |