Rails Paperclip how to delete attachment?

后端 未结 6 1077
小鲜肉
小鲜肉 2020-11-30 18:10

I am using Paperclip (w/ Amazon s3) on Rails 3. I want to delete an existing attachment without replacing it using an update action.

I\'ve only foun

6条回答
  •  情歌与酒
    2020-11-30 18:35

    Was able to achieve this with less code, by just implementing a delete_attachment on the model's side.:

    class MyModel < ApplicationRecord
      has_attached_file :image
    
      def image_delete=(other)
        self.image = nil if other == "1" or other == true
      end
    end
    

提交回复
热议问题