Paperclip is processing attachments even when they don't pass validation?

I have a model that uses paperclips for image attachments

I currently require that the attachment be an image using a validation

validates_attachment_content_type :image, :content_type => /^image\/(jpg|jpeg|pjpeg|png|x-png|gif)$/, :message => 'file type is not allowed (only jpeg/png/gif images)'

However when I try to upload a non-image I get these error messages.

Image /var/folders/1f/0jtzzpl56sdcb92spkx6rpch0000gn/T/10-21-201120120908-44073-j59q0s.pdf is not recognized by the 'identify' command.
Image /var/folders/1f/0jtzzpl56sdcb92spkx6rpch0000gn/T/10-21-201120120908-44073-j59q0s.pdf is not recognized by the 'identify' command.
Image content type file type is not allowed (only jpeg/png/gif images)

So it seems like the file is being passed to ImageMagick even though the file does not pass the validation. I want the last error message only and not the first 2.

How can I either suppress the two first messages or make sure that the file is not processed unless it passes the content type validation?

Answers


Check out following link, you might find your solution here by adding custom method https://groups.google.com/forum/?fromgroups=#!topic/paperclip-plugin/oVnIgfAfrLU

Thanks,

Nidhi Sarvaiya


Need Your Help

Poweshell remote application(.cmd) deployment

powershell powershell-v2.0 powershell-v3.0

I am beginner with PowerShell and struggling to get this around with the help from different sites, My requirement and scenario is

how to exclude special characters from regex?

jquery regex jquery-validate

I'm a very rookie with regexs, but this is very simple and i can't understand why it allows special characters like quotation marks or dots before the string when i use them in jquery validation pl...