1

I am using paperclip for storing files related to the model. The files can be in various formats depending on the description. I have specified following in the model:

require 'paperclip'

class Document < ActiveRecord::Base
  belongs_to :candidate
  attr_accessible :candidate_id, :description, :media

  has_attached_file :media, :styles => { :profile => "100x100>" }

  validates_attachment_presence :media
  validates_attachment_size :media, :less_than => 3.megabytes
end

Before sometime it was working fine. Recently after I had some system upgrades of archlinux (may be Imagemagick was upgraded), I have following error while saving certain formats e.g. .doc .xls etc, it works for images though.

* Media /tmp/stream20111020-2130-zeux3k-0.doc is not recognized by the 'identify' command.

When I run identify command with the file I get following.

$ identify  /tmp/stream20111020-2130-zeux3k-0.doc 
identify: no decode delegate for this image format `/tmp/stream20111020-2130-zeux3k-0.doc' @ error/constitute.c/ReadImage/532

Should Paperclip try to resize the word document at all ?

Anything, I can do about this ?

rangalo
  • 5,448
  • 8
  • 46
  • 66
  • 2
    This one works for me, try it! [http://stackoverflow.com/questions/5289674/paperclip-process-images-only][1] [1]: http://stackoverflow.com/questions/5289674/paperclip-process-images-only – Magesh Nov 11 '11 at 09:35

1 Answers1

0

I still don't know why it was working before and now doesn't wok, but I found out a workaround by supplying conditional style options to paperclip. Like following ...

has_attached_file :media, :styles => lambda { |attachment| (attachment.instance.description == "Foto") ? { :profile => "100x100>" }  : [] }

I still want to be more specific and specify style based on the content type

rangalo
  • 5,448
  • 8
  • 46
  • 66