OSDN Git Service

t30350#:fix destroy
[pettanr/pettanr.git] / app / models / comic.rb
index f32b0bd..e9b1298 100644 (file)
@@ -112,4 +112,16 @@ class Comic < ActiveRecord::Base
     Comic.count 'visible > 0'
   end
   
+  def destroy_with_story
+    res = false
+    Comic.transaction do
+      self.stories.each do |story|
+        raise ActiveRecord::Rollback unless story.destroy
+      end
+      raise ActiveRecord::Rollback unless self.destroy
+      res = true
+    end
+    res
+  end
+  
 end