Skip to content

Paperclip + Permanent records #804

link-er opened this Issue Mar 31, 2012 · 3 comments

2 participants

link-er commented Mar 31, 2012

I want to use paperclip gem with permanent_records gem ( but I have some problems. When I destroy attachment, not only deleted_at column is set to, but the file itself is deleted too - data_file_type, data_file_size and data_file_name is set to NULL.
Can I do something to avoid this?

thoughtbot, inc. member
sikachu commented Apr 4, 2012

What you could do is override prepare_for_destroy in your model to return true, or add some checking to see that it should destroy the attachment or not.

(Don't return false, as it will halt the chain)

You can see that Paperclip add the callback in which executes

@sikachu sikachu closed this Apr 4, 2012
link-er commented Apr 4, 2012

Thanks for answer, it helped!

link-er commented Jun 8, 2012
    def prepare_for_destroy

  def destroy(force = nil)
    if :force == force
      each_attachment do |name, attachment|

I did it in this way, because I do need files to be reoved when destroy is called with :force parametr. But I get an error

undefined method `queue_existing_for_delete' for #<Paperclip::Attachment:0xfc8cb34>

Can you help me please?

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.