Checking multiple types of content using the Paperclips and Rails program

I use the Paperclip gem for Rails so that users can upload the photo on their own. I obviously only want to accept jpeg , gif or png images. What is the correct way to check for these files, was downloaded instead of something else, such as a Word document?

According to the paperwork documents, I check the type of content with:

 validates_attachment :document, content_type: "application/pdf" 

What is the correct way to verify the above various image formats ( gif , png , jpeg )?

+7
ruby-on-rails ruby-on-rails-3 paperclip
source share
1 answer
 class Doc has_attached_file :document validates_attachment_content_type :image, :content_type => /^image\/(png|gif|jpeg)/, :message => 'only (png/gif/jpeg) images' end 
+9
source share

All Articles