OSDN Git Service

client is version0.4.35, added pettanr.comicReader.
[pettanr/pettanr.git] / app / models / system_picture.rb
index ba4bff8..9d01831 100644 (file)
@@ -1,8 +1,17 @@
 class SystemPicture < ActiveRecord::Base
+  has_many :balloons
+  has_many :balloon_templates
+  
+  before_destroy :destroy_with_file
+  
   def validate
     errors.add(:filesize, 'size over(1MB)') if self.filesize > 1000000
   end
   
+  def destroy_with_file
+    PictureIO.system_picture_io.delete self.filename
+  end
+  
   def dext
     self.ext.downcase
   end