I have a Rails 3 app using Paperclip 2.3.8. I have the following specified in my model:
validates_attachment_content_type :file,
:content_type => [\'ima
I think I figured out the problem.
Try removing the :styles
from your model and you will see that the 'identify' error message
goes way and the model validates as expected.
The problem is Paperclip is processing the styles even though the content_type
validation has failed. It tries to process your pdf as an image and then you get the error:
/var/folders/cs/cs-jiL3ZH1WOkgLrcqa5Ck+++TI/-Tmp-/stream20110404-43533-vm7eza.pdf
is not recognized by the 'identify' command.
The solution is to skip the processing if the validation fails, by adding this to your model:
before_post_process :skip_if_invalid
def skip_if_invalid
return false unless self.valid?
end
This way Paperclip won't try to turn files that are not images into thumbnails :)
it's not a weird. It is the most popular error for paperclip. And it's not about paperclip, actually, but about ImageMagick.
If you have istalled IM poperly now checkout its location:
which identify
#=> it will return some path
Create new file in your Rails application config/initializers/paperclip.rb
:
Paperclip.options[:command_path] = "path/to/identify"
Also you can add :whiny => false
option to your has_attached_file
has_attached_file :picture, :styles => { ... }, :whiny => false
So it won't throw any errors if something went wrong
Also you can read here if you want to store pictures and files in one model and want to ignore styling for non-image files:
Paperclip process images only