Explanation for validator of unique images added
This commit is contained in:
parent
ca7065dd5c
commit
308c89c9ea
1 changed files with 3 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue