From 82747a769089149d2ca8fb6a5a8608cc398cf6e1 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 10 Aug 2015 16:12:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=99=E8=A8=80=E6=B7=BB=E5=8A=A0=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 +++++--- app/models/user.rb | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0c5b441d4..39a467d53 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -262,9 +262,11 @@ class UsersController < ApplicationController # modified by fq def user_newfeedback jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - jours.update_all(:is_readed => true, :status => false) - jours.each do |journal| - fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) + if User.current == @user + jours.update_all(:is_readed => true, :status => false) + jours.each do |journal| + fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) + end end @jour = paginateHelper jours,10 @state = false diff --git a/app/models/user.rb b/app/models/user.rb index 2271adc18..1cd0675c8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -291,9 +291,10 @@ class User < Principal name end ## end - + + # 查询用户未读过的记录 def count_new_jour - count = self.new_jours.count + count = self.journals_for_messages.where("status=?", 1).count end #added by nie