diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-01-08 04:03:11 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-01-08 04:03:11 +0000 |
commit | 6dcfa742fded31c07101d9bea3122f49af83ea12 (patch) | |
tree | cf21a97bc93c247dd3969b915f71f6ad4e3b464a /app/models/board.rb | |
parent | ab6ac3b08fe84707c80ac74289ff630efe220932 (diff) | |
download | redmine-6dcfa742fded31c07101d9bea3122f49af83ea12.tar.gz redmine-6dcfa742fded31c07101d9bea3122f49af83ea12.zip |
Rails4: replace deprecated Relation#update_all at Board model
git-svn-id: http://svn.redmine.org/redmine/trunk@12503 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/board.rb')
-rw-r--r-- | app/models/board.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/board.rb b/app/models/board.rb index cb81e0a5a..dbfa8a3d4 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -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) |