Commit 36d1289d by Prem Sichanugrist

Clean up AttachmentContentTypeValidator conditions

parent bd528ba7
...@@ -6,12 +6,10 @@ module Paperclip ...@@ -6,12 +6,10 @@ module Paperclip
value = record.send(:read_attribute_for_validation, attribute) value = record.send(:read_attribute_for_validation, attribute)
allowed_types = [options[:content_type]].flatten allowed_types = [options[:content_type]].flatten
if value.present? if value.present? && allowed_types.none? { |type| type === value }
unless allowed_types.any? { |type| type === value } record.errors.add(attribute, :invalid, options.merge(
record.errors.add(attribute, :invalid, options.merge( :types => allowed_types.join(', ')
:types => allowed_types.join(', ') ))
))
end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment