开发者

Rails 3 user session gets destroyed while calling create from backbone collection

开发者 https://www.devze.com 2023-03-13 13:37 出处:网络
I have a backbone app which is being fed data by a Rails backend. When trying to call create from Backbone collection, the session in rails gets destroyed.

I have a backbone app which is being fed data by a Rails backend. When trying to call create from Backbone collection, the session in rails gets destroyed. Any pointers o开发者_高级运维n how to overcome it?


This sort of thing is almost always a result of a bad or non-existent CSRF token. In recent versions of Rails 3.0.4+, any request that doesn't have a CSRF token that matches the token generated for the users current session will destroy the session as a security measure.

Here is some more info on CSRF security in Rails:
http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf

You can easily test to see if this is what is causing your problem by commenting out the protect_from_forgery method call (probably in your application_controller.rb file). But I wouldn't recommend disabling it permanently for security reasons.

0

精彩评论

暂无评论...
验证码 换一张
取 消