thoughtbot/paperclip — pull request #1371 by krzychk (2013-10-28 18:08:30+00:00)
Title: Prevent file deletion on transaction rollback

Changed ```after_destroy``` callback to ```after_commit :on => :destroy``` in ```Paperclip::HasAttachedFile```.
This will prevent attachment deletion when transaction rollbacks after model is destroyed.

Example before fix:
```ruby
File.exists?(image.attachment.path) # => true
ActiveRecord::Base.transaction do
image.destroy
raise ActiveRecord::Rollback
end
File.exists?(image.attachment.path) # => false
```

Example after fix:
```ruby
File.exists?(image.attachment.path) # => true
ActiveRecord::Base.transaction do
image.destroy
raise ActiveRecord::Rollback
end
File.exists?(image.attachment.path) # => true
```