Paperclip preserve files ?

Hi,

     I am using paperclip to upload files. The problem I am facing is, based on my object property I need to preserve my file. Means my object should be deleted from db but the file need to be restored.

     I am using the option :preserve_files => true.      If I keep the above option in model it will be access to all the objects of the model. I need to restore only for limited objects.

     for example

     def destroy        if obj.restore_attachment          Paperclip::Attachment.default_options.merge!(:preserve_files =>true)        end        Paperclip::Attachment.default_options.merge!(:preserve_files =>false)        obj.destroy      end

     If you observe depending on the attachment property I am setting the option.

         obj.restore_attachment = true          obj.save      For obj.destroy          obj is getting deleted and file is getting restored.

         obj1.restore_attachment = false          obj1.save      For obj1.destroy          obj1 is getting deleted and file is also getting restored.          For obj1 this should not be happened. The file should also get deleted.

         Even I tried passing lambda in the model       has_attached_file :attachment ,:preserve_files => lambda{|obj| obj.restore_attachment ? true : false }

     This also behaves as like first approach.

     What I observe is when we set preserve_files => true the paperclip is taking this option only through out the other requests.

     How to reload paperclip in the code with new options

     Can you please suggest any alternate solution.

Cheers, Venkat.