简体   繁体   中英

Shrine gem - how to delete uploaded images from s3

显然:remove_attachment插件可以完成检查和提交工作,但是如何从控制器中调用该方法呢?

All plugins which allow you to set up form fields ( remove_attachment , remote_url , data_uri , ...) work in a way that they add getters and setters to your models, so if you have a Photo model with "image" attachment, you can do photo.remove_image = true .

However, for removing attachments in Ruby code you don't need the remove_attachment plugin, you can just assign the attachment to nil :

photo.image = nil
# or
photo.update(image: nil)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM