User in my web app are able to upload file. I use Paperclip to handle file attachment issue. Is there an开发者_开发问答y method if I would like to remove any specific user-uploaded file programmatically?
Ruby's File
class has a delete
method:
File.delete(Rails.root + '/foo.jpg')
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...
精彩评论