Paperclip validates_attachment_content_type for mp3 triggered when attaching mp3

Posted by zoltarSpeaks on Stack Overflow See other posts from Stack Overflow or by zoltarSpeaks
Published on 2009-11-17T20:27:45Z Indexed on 2010/05/04 9:48 UTC
Read the original article Hit count: 842

Hey everyone,

Struggling to workout when i add the following validtion to my Voice model using paperclip, it is being triggered when i try and upload an mp3:

class Voice < ActiveRecord::Base
  has_attached_file :clip

  validates_attachment_presence :clip
  validates_attachment_content_type :clip, :content_type => [ 'application/mp3', 'application/x-mp3', 'audio/mpeg', 'audio/mp3' ],
                                    :message => 'file must be of filetype .mp3'

  validates_attachment_size :clip, :less_than => 10.megabytes                                    

  validates_presence_of :title      
end

I have tried a number of different mp3 files but none of them seem to upload because the validation is failing.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about paperclip