优化用户留言页面

This commit is contained in:
huang 2015-09-18 14:04:02 +08:00
parent 90bf4a7c99
commit 81743143c2
1 changed files with 6 additions and 6 deletions

View File

@ -114,6 +114,7 @@ class UsersController < ApplicationController
end end
@user_system_messages = SystemMessage.where("created_at >?", contrast_time).order("created_at desc") @user_system_messages = SystemMessage.where("created_at >?", contrast_time).order("created_at desc")
# 当前用户查看消息,则设置消息为已读 # 当前用户查看消息,则设置消息为已读
# DO 待优化,只需查出符合条件的再更新
if params[:viewed] == "all" if params[:viewed] == "all"
course_querys = @user.course_messages course_querys = @user.course_messages
forge_querys = @user.forge_messages forge_querys = @user.forge_messages
@ -632,12 +633,11 @@ class UsersController < ApplicationController
redirect_to signin_url redirect_to signin_url
return return
end end
# 更新用户留言消息状态 # 自己访问自己的页面才更新消息状态
@user.journals_for_messages.each do |jour_message| if User.current == @user
jour_message.user_feedback_messages.each do |userfeedback_message| journals_messages = UserFeedbackMessage.where("user_id =? and journals_for_message_type =? and viewed =?", User.current.id, "JournalsForMessage", 0)
if User.current.id == userfeedback_message.user_id journals_messages.each do |journals_message|
userfeedback_message.update_attributes(:viewed => true) journals_message.update_attributes(:viewed => true)
end
end end
end end
# end # end