【发布时间】:2012-03-29 23:11:21
【问题描述】:
my Rails app 中的 2 个地方有 ajax 调用。 (一种用于 jQueryUI 拖放排序,一种用于更新评论帖子)。
每当发生这些调用时,用户都会被注销。没有明显的原因。 我正在使用omniauth-facebook 和omniauth-google-oauth2 进行身份验证。
如何解决这个问题?
下面是 ajax 调用的样子(coffeescript):
$.ajax({
type: 'put',
data: {post_id: post.attr("id")},
dataType: 'json',
complete: -> post.children('.headpost').children('.buttons').removeClass('new_reply'),
url: '/posts/update/'})
谢谢!
【问题讨论】:
-
weblog.rubyonrails.org/2011/2/8/… 好的,会话被重置,因为我的 ajax 请求没有真实性令牌。现在,如何使用资产咖啡脚本文件中的 ajax 请求来做到这一点...
标签: ajax ruby-on-rails-3 session csrf logout