Reputation: 3710
User in my web app are able to upload file. I use Paperclip to handle file attachment issue. Is there any method if I would like to remove any specific user-uploaded file programmatically?
Upvotes: 2
Views: 11751
Reputation: 1680
Deleting it should be as simple as setting it to nil
# assuming...
has_attached_file :picture
@thing.picture = nil
@thing.save
or
@thing.update_attribute(:picture, nil)
and Paperclip will take care of it for you...
Upvotes: 7
Reputation: 115372
Ruby's File
class has a delete
method:
File.delete(Rails.root + '/foo.jpg')
Upvotes: 36