How can I restrict Paperclip to only accept images?

ben picture ben · Jan 13, 2011 · Viewed 7.8k times · Source

How can I restrict Paperclip to only accept images? I'm using Amazon S3 for storage if that's relevant. Thanks for reading.

Answer

moonpatrol picture moonpatrol · Apr 8, 2012

From https://makandracards.com/makandra/606-only-allow-pictures-as-paperclip-attachments

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)'