Rails callbacks and the Paperclip plugin

Posted: January 23rd, 2009 | Author: jgeiger | Filed under: Uncategorized | Tags: | 3 Comments »

I had an issue with adding my own before_destroy hook to remove some files from S3 after deleting a record. Paperclip has a before_destroy hook that removes the attachments, and I was using the filename it provides to delete the remote files. It seems that the order of the before_destroy lines is important (which makes sense) but you need to be aware if it exists in a plugin you’re using.

In the case of Paperclip, I needed to put my custom hook before the has_attached_file declaration.

This comment helped me out http://apidock.com/rails/ActiveRecord/Callbacks/before_destroy#43-Where-you-declare-before-destroy-matters


3 Comments on “Rails callbacks and the Paperclip plugin”

  1. 1 Mike Larkin said at 1:09 am on July 7th, 2009:

    Thank you! This was driving me nuts!

  2. 2 Fadhli said at 2:14 am on July 17th, 2009:

    Thanks. This pretty much solved my problem.

  3. 3 Hemant said at 5:35 am on May 27th, 2010:

    Thanks! that solved my issue.


Leave a Reply