OSDN Git Service

t#31671:add elm copy
[pettanr/pettanr.git] / app / models / speech.rb
index 134c038..726f26d 100644 (file)
@@ -38,6 +38,14 @@ class Speech < ActiveRecord::Base
     self.speech_balloon
   end
   
+  def get_panel_id
+    if self.get_speech_balloon == nil or self.get_speech_balloon.panel == nil or self.get_speech_balloon.panel.new_record?
+      0
+    else
+      self.get_speech_balloon.panel.id
+    end
+  end
+  
   def tag_id c = nil
     'panel' + tag_panel_id + tag_element_type + tag_element_id + tag_element_part_type + tag_element_part_id + c.to_s
   end
@@ -47,11 +55,16 @@ class Speech < ActiveRecord::Base
   end
   
   def tag_panel_id
-    self.get_speech_balloon.panel.new_record? ? '0' : self.get_speech_balloon.panel.id.to_s
+    self.get_panel_id.to_s
   end
   
   def tag_element_id
-    self.get_speech_balloon.new_record? ? '0' : self.get_speech_balloon.id.to_s
+    r = if self.get_speech_balloon == nil or self.get_speech_balloon.new_record?
+      0
+    else
+      self.get_speech_balloon.panel.id
+    end
+    r.to_s
   end
   
   def tag_element_type