Permalink
Browse files

Clean up AttachmentContentTypeValidator conditions

  • Loading branch information...
1 parent bd528ba commit 36d1289d0cd561e3b99ccfd8646b5ee9a6ec1ac4 @sikachu sikachu committed Mar 27, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 lib/paperclip/validators/attachment_content_type_validator.rb
@@ -6,12 +6,10 @@ def validate_each(record, attribute, value)
value = record.send(:read_attribute_for_validation, attribute)
allowed_types = [options[:content_type]].flatten
- if value.present?
- unless allowed_types.any? { |type| type === value }
- record.errors.add(attribute, :invalid, options.merge(
- :types => allowed_types.join(', ')
- ))
- end
+ if value.present? && allowed_types.none? { |type| type === value }
+ record.errors.add(attribute, :invalid, options.merge(
+ :types => allowed_types.join(', ')
+ ))
end
end

0 comments on commit 36d1289

Please sign in to comment.