Commit 36d1289d by Prem Sichanugrist

Clean up AttachmentContentTypeValidator conditions

parent bd528ba7
......@@ -6,14 +6,12 @@ module Paperclip
value = record.send(:read_attribute_for_validation, attribute)
allowed_types = [options[:content_type]].flatten
if value.present?
unless allowed_types.any? { |type| type === value }
if value.present? && allowed_types.none? { |type| type === value }
record.errors.add(attribute, :invalid, options.merge(
:types => allowed_types.join(', ')
))
end
end
end
def check_validity!
unless options.has_key?(:content_type)
......
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