修改排序

This commit is contained in:
huang 2015-08-20 17:40:01 +08:00
parent 29b8a9dd9d
commit 840caf18f3
1 changed files with 12 additions and 6 deletions

View File

@ -105,17 +105,23 @@ class UsersController < ApplicationController
return
end
# 当前用户查看消息,则设置消息为已读
querys = @user.course_messages
course_querys = @user.course_messages
forge_querys = @user.forge_messages
user_querys = @user.user_feedback_messages
forum_querys = @user.memo_messages
if User.current.id == @user.id
querys.update_all(:viewed => true)
course_querys.update_all(:viewed => true)
forge_querys.update_all(:viewed => true)
user_querys.update_all(:viewed => true)
forum_querys.update_all(:viewed => true)
end
@new_message_count = @user.forge_messages.count + @user.memo_messages.count + @user.course_messages.count + @user.user_feedback_messages.count
case params[:type]
when nil
@user_course_messages = @user.course_messages.reverse
@user_forge_messages = @user.forge_messages.reverse
@user_memo_messages = @user.memo_messages.reverse
@user_feedback_messages = @user.user_feedback_messages.reverse
@user_course_messages = CourseMessage.where("user_id =?",@user).order("created_at desc")
@user_forge_messages = ForgeMessage.where("user_id =?",@user).order("created_at desc")
@user_memo_messages = MemoMessage.where("user_id =?",@user).order("created_at desc")
@user_feedback_messages = UserFeedbackMessage.where("user_id =?",@user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
@user_forge_messages_count = @user_forge_messages.count
@user_memo_messages_count = @user_memo_messages.count