class Attachs::Extensions::ActiveRecord::Validations::AttachmentContentTypeValidator
Public Instance Methods
validate_attachment(record, attachment)
click to toggle source
# 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