From 308c89c9eac692080685a7738498e0aac60bd169 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Mon, 27 Apr 2015 00:54:57 +0200 Subject: [PATCH] Explanation for validator of unique images added --- app/models/screenshot.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)