添加点击对应方法

This commit is contained in:
huang 2015-09-06 17:42:10 +08:00
parent b2e25e8afc
commit ed5f14c9eb
1 changed files with 10 additions and 0 deletions

View File

@ -105,6 +105,16 @@ class UsersController < ApplicationController
redirect_to signin_url redirect_to signin_url
return return
end end
# 记录当前点击按钮的时间
if OnclickTime.where("user_id =?", User.current).first.nil?
message_new_time = OnclickTime.new
message_new_time.user_id = User.current.id
message_new_time.onclick_time = Time.now
message_new_time.save
else
message_new_time = OnclickTime.where("user_id =?", User.current)
message_new_time.update_attributes(:onclick_time => Time.now)
end
# 当前用户查看消息,则设置消息为已读 # 当前用户查看消息,则设置消息为已读
if params[:viewed] == "all" if params[:viewed] == "all"
course_querys = @user.course_messages course_querys = @user.course_messages