views:

292

answers:

1

Hi,

I have systematically an error when I'm trying to upload a file that is not in ["image/jpg", "image/jpeg", "image/gif", "image/png", "image/pjpeg", "image/x-png"]

When I try to upload a file like a wav I have this message * Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'identify' command. * Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'identify' command. * Photo content type Accepted files include: jpg, gif, png

So it detects that the file is not an image and display my message "Accepted files include: jpg, gif, png" but I have this extra message included before mine Photo is not recognized by the 'identify' command... Upload works fine for pictures

My code is: Controller
def upload
@picture= Picture.new(params[:picture])
if [email protected]?
render :form
end
end

View form
<%= error_messages_for :picture, :header_message => nil, :message => nil %>
<% form_for :picture, @picture, :name => "uploadPic", :url => { :action => 'upload_data'}, :html => {:name => 'uploadForm', :multipart => true } do |form| %>
<%= form.file_field :photo %>
<%= submit_tag 'Save'%>
<% end %>

Picture model class Picture < ActiveRecord::Base
require 'paperclip'
has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" }

    validates_attachment_size :photo, :less_than => 2.megabytes , :message => "must be less than 2 megabytes"  
    validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/gif", "image/png", "image/pjpeg", "image/x-png"], :message => "Accepted files include: jpg, gif, png"   

end

+1  A: 

solved it with :whiny => false
has_attached_file :photo, :whiny => false, :styles => { :medium => "300x300>", :thumb => "100x100>" }

Mathieu