【发布时间】:2014-09-10 19:30:45
【问题描述】:
我发现这个solution 使用复选框作为标志来删除图像。但是,我想使用link_to。基本上,在图片附件旁边,我想要一个“删除头像”链接。如果可能,我希望链接只删除图像,而不更新其他属性。
用户类
class User < ActiveRecord::Base
has_attached_file :avatar
attr_accessible :avatar
在表格中
link_to "Delete Avatar", {:action => :update}, :method => :put
显然,这实际上并没有删除图像。最好的方法是什么?链接是否设置了隐藏标志然后更新?或者这只是一个坏主意(如果是这样,为什么)?
【问题讨论】: