diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 0962deb10..dbefd82cb 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -108,15 +108,11 @@ class NewsController < ApplicationController def show # 更新news对应的forge_messages的消息viewed字段 if @project - query_message_news = @news.forge_messages + query_message_news = ForgeMessage.where("forge_message_id =? and user_id =?", @news.id, User.current.id).first else - query_message_news = @news.course_messages - end - query_message_news.each do |query| - if User.current.id == query.user_id - query.update_attributes(:viewed => true) - end + query_message_news = CourseMessage.where("course_message_id =? and user_id =?", @news.id, User.current.id).first end + query_message_news.update_attribute(:viewed, true) # 更新项目新闻的评阅的消息viewed字段 current_message_comments = @news.comments current_message_comments.each do |current_message_comment|