Browse Source

remove image if nil and previous exists

Kylie Jo Swistak 5 years ago
parent
commit
1a4912fdd0
1 changed files with 5 additions and 0 deletions
  1. 5 0
      app/controllers/image_controller.rb

+ 5 - 0
app/controllers/image_controller.rb

@@ -2,6 +2,11 @@ class ImageController
   def self.default_image(url, char_id, rating)
     image = CharImage.where(char_id: char_id).find_by(keyword: 'Default')
 
+    if url == nil
+      image.destroy if image
+      return
+    end
+
     if image
       image.update(url: url)
     else