Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


use after_commit instead of after_destroy for removing attached files? #1020

xxx opened this Issue · 0 comments

1 participant



I noticed that attachments are being removed in an after_destroy callback, which runs within the database transaction, but doesn't seem to need to. ActiveRecord 3.0 added after_commit as a callback, which runs after the transaction completes successfully, and seems to be more appropriate for this situation.

As of now, I'm patching around with the following to do this:

has_attached_file blah blah

skip_callback, :destroy, :after, :destroy_attached_files
after_commit :destroy_attached_files, :on => :destroy

which is working fine. Is there a reason it shouldn't be done this way, that I'm not aware of?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.