可能重复:
警告:无法验证 CSRF 令牌真实性轨道
我使用 JQuery AJAX 发送 DELETE HTTP 请求。URL (/myitems/1234) 与注销 URL (/users/sign_out) 不同,但是在请求之后我发现用户会话被破坏了。
我正在使用设计身份验证 gem。
这是日志:
Started DELETE "/myitems/2538" for 127.0.0.1 at 2012-06-26 19:09:49 +0400
Processing by MyItemsController#destroy as */*
Parameters: {"id"=>"2538"}
WARNING: Can't verify CSRF token authenticity
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 6 LIMIT 1
(0.0ms) BEGIN
(0.0ms) UPDATE "users" SET "remember_token" = NULL,
"remember_created_at" = NULL,
"updated_at" = '2012-06-26 15:09:49.055774'
WHERE "users"."id" = 6
(1.0ms) COMMIT
Completed 401 Unauthorized in 7ms
routes.rb 包含一行:
resources :myitems
仅此而已。
控制器的删除代码:
def destroy
puts 'delete'
end
更新
POST 请求也是如此。