Parcourir la source

remove image if nil and previous exists

Kylie Jo Swistak il y a 5 ans
Parent
commit
1a4912fdd0
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  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