2010-12-14 85 views
12

我剛升級到rails3,當我安裝了我平常的attachment_fu插件失敗。所以我開始使用Google搜索,儘管我確實設法找到了rails3版本,但似乎有更多的人在討論與rails3的回形針。Attachment_fu或Paperclip for Rails3

那麼首先有什麼回形針的優點?

有更好的支持rails3嗎?

回答

12

也沒有。使用carrierwave

To handle the file uploads, I’ve switched from Paperclip to CarrierWave. While Paperclip has (and continues) to serve me well in many applications I work with, I really appreciate the modular approach that CarrierWave takes. It’s agnostic as to which of the popular S3 clients you use, supporting both aws/s3 and right_aws. It’s also ORM agnostic and not tightly coupled to Active Record. The tight coupling of Paperclip has caused us some grief at work, and I’m also confused about the state of Paperclip’s support for aws/s3 and right_aws. So, I was happy to find this new project, and the maintainer Jonas Nicklas seems to be an extremely responsive and helpful dude, which is always good thing. The code looks great, and I’ve had an easy time working with this library so far. (from: http://trevorturk.com/2010/2/8/kzak-an-open-source-web-based-jukebox/)

此處瞭解詳情:

+0

好的謝謝你現在看到它的建議,看起來很有趣。 – 2010-12-15 09:21:45

+0

是的,Carrierwave非常棒,它現在使用Fog庫來支持S3。我強烈推薦它。你也可以使用Paperclip兼容模式,所以如果你想隨時切換到Paperclip,那真的很容易。 – 2010-12-30 01:01:32

7

我做attachment_fu Rails3中兼容。

https://github.com/mihael/attachment_fu

編輯:但它打破了一些用戶,我沒有進一步的維護,所以請考慮其他的解決方案,如果你不希望自己破解它;)

我正在爲我正在開發的一個項目測試paperclip vs carrierwave vs attachment_fu與rails3.0.3。

到目前爲止attachment_fu一如既往地工作,但代碼仍然需要一些重構與回調系統。它有後端的雲文件,s3。

回形針也非常好,很容易使用。基本設置沒有讓我上傳電影(必須添加選項:whiny => false),並且它沒有按照我的預期清理文件名。這是我如何做到的:

class Asset < ActiveRecord::Base 
    has_attached_file :file, :styles => { :small => "300x300>", :thumb => "50x50>" }, :whiny => false 
    before_create :sanitize_file_name 
    private 
    def sanitize_file_name 
    self.file.instance_write(:file_name, file_file_name.gsub(/[^A-Za-z0-9\.\-]/, '_')) 
    end 
end 

回形針有s3後端,但沒有用於內置雲文件的後端。這是一個回形針叉(爲paperclip雲文件),它是爲rails2.3.5(搜索github for paperclip_demo)構建的。

Carrierwave看起來非常漂亮,與分離的架構,但我不喜歡這樣的事實,它不上的更新和對象的破陣刪除任何東西,留下一堆磁盤上的文件和目錄。基本的載波設置也沒有讓我上傳電影,雖然它很好地清理文件名。我還沒有找到一個快速解決方案。如果您正在使用Mongoid和GridFS,carrierwave已經內置支持。

最後,我把Paperclip用於我的項目。

+1

乾杯,但我試過你的叉子,並得到一個錯誤:失效保護響應期間出現錯誤:ActionView :: Template :: Error。 ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/whiny_nil.rb:48:在'method_missing' – 2011-04-16 19:40:35

0

Dragonfly確實不錯。試試看,它可以處理文件和圖像。

+0

不確定我看到優於其他系統嗎?我一直在使用載波,似乎工作得很好。我喜歡將代碼從模型中分離出來。 – 2011-06-22 08:11:42