]> source.dussan.org Git - redmine.git/commitdiff
Rails4: replace deprecated Relation#update_all at Board model
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 8 Jan 2014 04:03:11 +0000 (04:03 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 8 Jan 2014 04:03:11 +0000 (04:03 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12503 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/board.rb

index cb81e0a5ae9f3e2a9e27b647dcfc2b548a817a7b..dbfa8a3d407be4e1a868de7926b8fc9d5b2676dd 100644 (file)
@@ -60,10 +60,10 @@ class Board < ActiveRecord::Base
   # Updates topics_count, messages_count and last_message_id attributes for +board_id+
   def self.reset_counters!(board_id)
     board_id = board_id.to_i
-    update_all("topics_count = (SELECT COUNT(*) FROM #{Message.table_name} WHERE board_id=#{board_id} AND parent_id IS NULL)," +
+    where(["id = ?", board_id]).
+      update_all("topics_count = (SELECT COUNT(*) FROM #{Message.table_name} WHERE board_id=#{board_id} AND parent_id IS NULL)," +
                " messages_count = (SELECT COUNT(*) FROM #{Message.table_name} WHERE board_id=#{board_id})," +
-               " last_message_id = (SELECT MAX(id) FROM #{Message.table_name} WHERE board_id=#{board_id})",
-               ["id = ?", board_id])
+               " last_message_id = (SELECT MAX(id) FROM #{Message.table_name} WHERE board_id=#{board_id})")
   end
 
   def self.board_tree(boards, parent_id=nil, level=0)