使用Paperclip删除图像
我正在使用Paperclip在我的Rails应用程序中保存图片:
用户模型:
class User < ActiveRecord::Base has_one :profile end
档案型号:
class Profile {:medium => "300x300>", :thumb => "100x100>"} belongs_to :user end
我尝试删除头像:
current_user.profile.avatar = nil current_user.profile.save
但它不起作用。 可能吗?
profile = current_user.profile profile.avatar.destroy profile.save
你无法以这种方式保存对象current_user.profile.save