Created
March 5, 2010 16:33
-
-
Save paolochiodi/322888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
monkey patch to generate paperclip validation errors on attachment and not only attachment_suffix