From 851521dc475e3d434ff8e13bd9f9e558aa9af772 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 14 Nov 2024 16:14:33 +0000 Subject: Improved the feature slot handling - can now remove feature_slot value --- app/models/pdfresource.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/models/pdfresource.rb') diff --git a/app/models/pdfresource.rb b/app/models/pdfresource.rb index 4fa2292..8e59972 100644 --- a/app/models/pdfresource.rb +++ b/app/models/pdfresource.rb @@ -4,7 +4,8 @@ class Pdfresource < ApplicationRecord has_many_attached :pdf_snapshots belongs_to :resource_type validates :feature_slot, - numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 3, allow_nil: true }, + 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 -- cgit v1.2.3