diff --git a/app/models/screenshot.rb b/app/models/screenshot.rb index 9121090..a9b4c2c 100644 --- a/app/models/screenshot.rb +++ b/app/models/screenshot.rb @@ -14,7 +14,9 @@ class Screenshot < ActiveRecord::Base validates_with AttachmentSizeValidator, :attributes => :image, :less_than => 5.megabytes validate :validate_image_is_unique - # Validator that checks if the image has already been uploaded + # Validator that checks if the image has already been uploaded. + # A generic uniqueness validator does not work because it would attribute + # the error to the :image_fingerprint field and not the actual :image field. def validate_image_is_unique # Look for images with the same checksum / image_fingerprint if Screenshot.find_by(image_fingerprint: image_fingerprint)