Agile Web Development

Build it. Launch it. Love it.

Attachment Fu

attachment_fu is a plugin by Rick Olson (aka technoweenie) and is the successor to acts_as_attachment. To get a basic run-through of its capabilities, check out Mike Clark’s tutorial http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu.

Vitals

Repository git://github.com/technoweenie/attachment_fu.git
License Rails' (MIT)
Tags Tag_red attachment file hdfh image nilesh nileshKul paginator resize thumbnails upload upload uyuyu vvcb yuyuytu
Rating (109 votes)
Owner Rick Olson
Created 19 February 2007

Comments

  • Avatar
    20 April 2007

    What's the motivation behind the re-write?

  • Avatar
    Peter
    20 June 2007

    Note: Only allows 1 attachment per model (as of june 2007). I'm 'bout to hack myself an attachment_fufu...

  • Avatar
    Peter
    17 December 2007

    I was unable to get the Amazon S3 backend to work properly (in Rails 2).

  • Avatar
    22 February 2008

    If you want more than one attachment per model check out the file_column plugin. It doesn't have S3 support but it allows you to treat a file as just another column type in your database.

  • Avatar
    15 June 2008

    using the callback:
    after_resize do |record, img|
    record.size = img.filesize
    end
    used to work fine with rails 1.2.6

    but I upgraded to 2.1 and get the error message:
    The error occurred while evaluating nil.filesize

    Then I applied the patch from:
    http://blog.methodmissing.com/2008/1/19/edge-callback-refactorings-attachment_fu/

    On the bottom of attachment_fu.rb and I got the error message:
    undefined method `run' for ActiveSupport::Callbacks::Callback:Class

    Please, I need help to fix this.

    Thank you.

  • 21 August 2008

    I've been using this plugin with great success but the default error messages suck...

  • Avatar
    Piers Goodhew
    27 August 2008

    Pablo - I've got the same problem; can't try it myself yet, but I see Rick Olsen has updated attach_fu back in march for Rails 2.x - he credits methodmissing, but his changes are different (and after all the methodmissing changes are for edge rails not plain vanilla shipping rails).

    That's what I'll be trying next: updating the plugin from techo-weenie.

  • Avatar
    B Casadonte
    27 August 2008

    Having a problem using Attachment Fu with Single Table Inheritance. Seems like they don't get along too well... keep getting an error "undefined method for "attachmentoptions". This occurs when calling .publicfilename on a model object (ie: content.image.public_filename). Works the first time, but all subsequent attempts result in the error.

  • Avatar
    jm
    2 October 2008

    I have the same problem as Pablo. Any chance someone can update the plugin. I have looked in the code but i think i am not good enough to find a solution... :(

    I just downgraded to 2.0.2...

  • Guillaume
    14 October 2008

    From Windows, saving to the DB requires some tweaking. See http://epirsch.blogspot.com/2008/01/fixing-attachmentfu-on-windows-like.html

    (The problem was that saving to the DB was not working. Partial info was saved)

  • Avatar
    13 November 2008

    Hi Piers and jm. Just encountered the same problem and found the following patch which with a small amend works on 2.1... http://blog.methodmissing.com/

    Here is the full patch for attribute_fu.rb... def callbackwithargs(method, arg = self) notify(method)

         result = run_callbacks(method, { :object => arg }) { |result, object| result == false }
    
         if result != false && respond_to_without_attributes?(method)
           result = send(method)
         end
    
         return result
       end      
    
       def run_callbacks(kind, options = {}, &block)
         options.reverse_merge!( :object => self )
    

    ActiveSupport::Callbacks.run(self.class.send("#{kind}callbackchain"), options[:object], options, &block)

         self.class.send("#{kind}_callback_chain").run(options[:object], options, &block)
       end
    
  • Avatar
    18 November 2008

    Hi Rick,

    Love the plugin. Couldn't find a place to submit this bug report, but I get this in my mongrel log file about once a month:

    imagescienceprocessor.rb:14: [BUG] Segmentation fault

    If anyone has any info on this please drop me a line. I have FreeImage 3.9 installed on Ubuntu. Brian

  • Trevor
    13 February 2009

    It looks like this attachment_fu doesn't work with an Oracle DB, because 'size' is a special keyword. This could be handled at the DDL layer by outputing \"size\" in all the SQL, or by changing this plugin's convention to, say, dimension(s). Alas.

  • Avatar
    Javix
    10 April 2009

    I can't understand why I can't upload a file even if its size is OK; I just added to my model:

    hasattachment :maxsize => 10.megabytes
    validates_as_attachment. I tried to upload a file of 2.8 Mb, when debugging its size waz at 0; WHY?????

  • Hans
    3 June 2009

    If you don't need the size attribute and are using Oracle (ie - not storing images), then do NOT put the size attribute in the table, and instead fake it in the model with 'attr_accessor :size'

    That hack saved a lot of time for our dev team.

  • Avatar
    Kishore
    4 June 2009

    It's a greatest plugin. Resizing image and creating thumbnails are very easy. simply amazing.

    But if i use the "validates_as_attachment" in model it gives the following error "size is not included in the list". If i eliminate this line from model it works fine in all aspects.

Add a comment