Attachment_fu or Paperclip for Rails3
Asked Answered
E

4

12

I have just upgraded to rails3 and when I installed my usual attachment_fu plugin failed. So I started googling it and although I did manage to find a rails3 version there seemed to be a lot more people talking about paperclip with rails3.

So firstly what are the advantages of paperclip?

Is there better support for rails3 with it?

Encephalo answered 14/12, 2010 at 23:12 Comment(0)
D
12

Neither. Use 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/)

More info here:

Deactivate answered 14/12, 2010 at 23:18 Comment(2)
Ok thanks for the advice looking into it now, looks very interesting.Encephalo
Yes, Carrierwave is great, and it's now using the Fog library for S3 support. I'd highly recommend it. You can also use the Paperclip compatibility mode, so if you want to switch to Paperclip anytime it'd be really easy.Hades
I
7

I made attachment_fu rails3 compatible.

See https://github.com/mihael/attachment_fu

EDIT: but it is broken for some users, and i am not maintaining it further, so please look into other solutions, if you do not want to hack it yourself ;)

I tested paperclip vs carrierwave vs attachment_fu with rails3.0.3 for a project I am working on.

So far attachment_fu works very well as always, but the code still needs some refactoring with the callback system. It has backends for cloudfiles, s3.

Paperclip is also very good and is very easy to use. The basic setup did not let me upload movies (had to add option :whiny=>false), and it did not sanitize filenames the way I expected. This is how I did it:

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

Paperclip has s3 backend, but does not have a backend for cloudfiles built-in. There is a paperclip fork for that (google for paperclip-cloudfiles) which is built for rails2.3.5 (search github for paperclip_demo).

Carrierwave looks very nice, with the decoupled architecture, but I do not like the fact that it does not delete stuff on updates and destroys of objects, leaving a bunch of files and directories on disk. The basic carrierwave setup also did not let me upload movies, although it sanitizes filenames nicely. I did not found a quick fix for this, yet. If You are using Mongoid and GridFS, carrierwave has built in support.

Finally, I took Paperclip for my project.

Inboard answered 20/12, 2010 at 16:21 Comment(1)
Cheers, but I tried your fork and got an error: Error during failsafe response: ActionView::Template::Error. ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/whiny_nil.rb:48:in `method_missing'Cowper
P
2

I've created a gem for attachment_fu if you want to continue using it in Rails 3.2 and beyond.

https://rubygems.org/gems/pothoven-attachment_fu

Peery answered 13/3, 2013 at 16:54 Comment(0)
P
0

Dragonfly is really good. Try it out, it can handle files and images.

Perigordian answered 21/6, 2011 at 21:55 Comment(1)
Not sure I see the advantage over other systems? I've been using carrierwave and seems to work very well. I like the separation of the code from the models.Encephalo

© 2022 - 2024 — McMap. All rights reserved.