2012-05-10 24 views
0

我能夠接受使用回形針上傳.pdf,.gif.jpeg,但.doc.xls不起作用。回形針寶石支持.doc上傳與否?

模型回形針代碼如下所示:

has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" } 

這裏是遷移:

class AddAttachmentAvatarToDocuments < ActiveRecord::Migration 
    def self.up 
    add_column :documents, :avatar_file_name, :string 
    add_column :documents, :avatar_content_type, :string 
    add_column :documents, :avatar_file_size, :integer 
    add_column :documents, :avatar_updated_at, :datetime 
    end 

    def self.down 
    remove_column :documents, :avatar_file_name 
    remove_column :documents, :avatar_content_type 
    remove_column :documents, :avatar_file_size 
    remove_column :documents, :avatar_updated_at 
    end 
end 

我怎樣才能解決這個問題呢?

回答

2

爲什麼有人會使用.doc.xls作爲他們的頭像?

您正在告訴Paperclip製作上傳文件的縮略圖,該文件不適用於非image-y文件。如果您想允許上傳多種類型的文件,但只能爲圖像製作縮略圖,請嘗試conditionally resizing

+0

我無法上傳.doc文件也 – user1381579

+0

你用什麼處理器來生成縮略圖?例如,ImageMagick無法單獨處理'.doc's。 –

+0

我使用imagemagick現在我能夠上傳但無法制作doc或pdf文件的縮略圖 – user1381579