my Rails appに2か所がajaxコールを持っています。 (1つはjQueryUIドラッグアンドドロップソート、もう1つはコメント投稿の更新)。Ajax PUTリクエストは、Railsアプリケーションでログアウトします。どうして?
これらの呼び出しが発生するたびに、ユーザーはログアウトします。明白な理由なしに。 私は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/'})
ありがとう!
のhttp:/ /weblog.rubyonrails.org/2011/2/8/csrf-protection-bypass-in-ruby-on-rails/ 私のajaxリクエストに信頼性トークンがないので、セッションがリセットされます。さて、アセットのcoffeescriptファイルでajaxリクエストでそれを行う方法... – Arcolye