Cookie 溢出 &关联错误
我正在创建一个 Ruby on Rails 聊天室 Web 应用程序,但在尝试更新用户的“上次活动”时间时遇到了问题。每个“Client”模型都通过关联链接到“LoginStatus”模型。我每 5 秒轮询一次服务器并更新与客户端关联的模型的“latestNew”列。然而,专栏 1) 永远不会更新,2) 向我发送“Cookie 溢出”错误。这是我的代码。
jquery ajax 调用“updateLoginStatus”url
function updateLoginStatus () {
$.ajax({
url: "updateLoginStatus",
type: "POST",
success: function (data) {
//Nothing to do on success for now
}
})
}
控制器
def updateLoginStatus
currentUser = session[:user]
newestTime = currentUser.login_status
newestTime.latestTime = Time.now
newestTime.save
render :nothing => true
end
每次我检查控制台时,latestNew 列仍未更新。我应该如何解决这个问题?
I'm creating a Ruby on Rails chatroom web application but ran into a problem while trying to update "last active" times for a user. Each "Client" model is linked to a "LoginStatus" model through an association. Every 5 seconds I poll the server and update the "latestNew" column for the model that is associated with the client. However, the column 1) never updates and 2) shoots me a "Cookie Overflow" error. Here is my code.
jquery ajax call to the "updateLoginStatus" url
function updateLoginStatus () {
$.ajax({
url: "updateLoginStatus",
type: "POST",
success: function (data) {
//Nothing to do on success for now
}
})
}
The controller
def updateLoginStatus
currentUser = session[:user]
newestTime = currentUser.login_status
newestTime.latestTime = Time.now
newestTime.save
render :nothing => true
end
Every time I check the console the latestNew column is still not updated. How should I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在从可能包含用户 ID 的用户检索会话。通过这个用户 ID,您应该访问用户模型并找到这个特定的用户。之后,您可以在该对象上调用login_status。这是您需要在控制器中使用的代码:
You are retrieving the session from the user which probably contains the user-id. With this user-id you should access the User model and find this particular user. After that you are able to call login_status on the object. This is the code what you'll need to use in the controller: