0
votes

I have a model which has a paperclip attachment call spreadsheet.

The model is import which imports a spreadsheet data into the database.

I want to setup a task may be a rake task to clean up all the old imports (let's say older than 1 month).

I am not sure if this is the best way but this is what I found while searching.

The actual question is, when I destroy the model from a rake task, it doesn't delete the file from the system which is associated with the attachment. On the other hand, when I destroy the model from within the web application it destroys it.

What should I do to remove the attachment files along with destroying the model from a rake task ?

1

1 Answers

0
votes

You shouldn't see any difference between calling #destroy from your controllers or from rake. Perhaps you're confusing #delete and #destroy? #delete ignores callbacks and therefore won't allow paperclip to clean up its attachments.

Of course there's also issues related to file permissions. Are you running the rake task as the same user that runs the app for the web?