OSDN Git Service

t#32471:add profiles
[pettanr/pettanr.git] / app / models / balloon.rb
index 110a3aa..611481f 100644 (file)
@@ -98,6 +98,14 @@ self.system_picture_id = 1
     Kaminari.paginate_array(Array.new(Balloon.where(self.list_where()).includes(Balloon.list_opt).count, nil)).page(page).per(page_size)
   end
   
+  def self.list_by_speech_balloon_where speech_balloon_id
+    ['balloons.speech_balloon_id = ?', speech_balloon_id]
+  end
+  
+  def self.list_by_speech_balloon speech_balloon_id, roles, page = 1, page_size = self.default_page_size
+    self.where(self.list_by_speech_balloon_where(speech_balloon_id)).includes(self.list_opt).order('balloons.updated_at desc').offset((page -1) * page_size).limit(page_size)
+  end
+  
   def self.list_opt
     {:speech_balloon => {:panel => {:author => {}}, :speech => {}, :speech_balloon_template => {} }}
   end