class UploadValidator
If you pass in the presence: true option, this validator will assume you're using the CachedUploads module. It will look at the has_cached_upload config for the given attribute and check if a) the upload is present, b) the temporary MD5 hash is present, or c) the record has already been saved.
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/echo_uploads/validation.rb, line 78 def validate_each(record, attribute, value) if options[:presence] config = record.class.cached_uploads[attribute.to_sym] if record.new_record? and value.blank? and record.send(config[:md5_attr]).blank? record.errors[attribute] << (options[:message] || "can't be blank") end end if value.present? and value.size > options[:max_size] record.errors[attribute] << (options[:message] || "is too large (max is #{options[:max_size]} bytes)") end end