Paperclip: delete attachment and "can't convert nil into String" error
- by snitko
I'm using Paperclip and here's what I do in the model to delete attachments:
def before_save
self.avatar = nil if @delete_avatar == 1.to_s
end
Works fine unless @delete_avatar flag is set when the user is actually uploading the image (so the model receives both params[:user][:avatar] and params[:user][:delete_avatar]. This results in…