9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/attachs/extensions/active_record/validations/attachment_content_type_validator.rb', line 9
def validate_attachment(record, attachment)
unless attachment.blank?
if options.has_key?(:with)
if options[:with] !~ attachment.content_type
attachment.errors.add :value, :not_allowed
end
elsif options.has_key?(:in) || options.has_key?(:within)
list = (options[:in] || options[:within])
if list.exclude?(attachment.content_type)
attachment.errors.add :value, :can_only_be, list: list.to_sentence
end
end
end
end
|