Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save paolochiodi/322888 to your computer and use it in GitHub Desktop.
Save paolochiodi/322888 to your computer and use it in GitHub Desktop.
class ActiveRecord::Base
alias_method 'paperclip_valid?', 'valid?'
def valid?
ret = paperclip_valid?
unless self.class.attachment_definitions.nil?
self.class.attachment_definitions.each_key do |attachment|
%w(_file_name _content_type _file_size).each do |suffix|
error = errors.on("#{attachment}#{suffix}")
unless error.nil?
errors.add("#{attachment}", error)
end
end
end
end
ret
end
end
@paolochiodi
Copy link
Author

monkey patch to generate paperclip validation errors on attachment and not only attachment_suffix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment