Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的网络应用程序中的用户能够上传文件。我使用回形针来处理文件附件问题。如果我想以编程方式删除任何特定的用户上传的文件,有什么方法吗?
Ruby 的File类有一个delete方法:
File
delete
File.delete(Rails.root + '/foo.jpg')
删除它应该像将其设置为 nil 一样简单
# assuming... has_attached_file :picture @thing.picture = nil @thing.save
或者
@thing.update_attribute(:picture, nil)
回形针会为您处理好...