为ActiveRecordStore InvalidAuthenticityToken [英] ActiveRecordStore InvalidAuthenticityToken

查看:121
本文介绍了为ActiveRecordStore InvalidAuthenticityToken的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在使用cookie存储,我想变为有效的唱片店。不过,我不断收到一个无效的真实性令牌。删除我的饼干后,我能够访问该页面就好了,但我不希望我的所有用户前来我的网页,获得巨大的错误,然后弄清楚,我希望他们能够删除他们的饼干。

I have recently been using cookie store and I want to transition to active record store. However I keep getting an invalid authenticity token. After deleting my cookies, I was able to access the page just fine, but I don't want all my users to come to my page, get a huge error and then figure out that I want them to delete their cookies.

所以我做了一个名为删除cookies功能:

So I made a function called delete cookies:

  after_filter :delete_cookie
  def delete_cookie
    puts "deleting cookies"
    cookies.to_hash.each_pair do |k, v|
      puts k
      cookies.delete(k)
    end
  end

在应用控制器,但它似乎并没有被正常工作。我仍然看到访问的任何页面后,我的cookie。我觉得真的应该有更好的解决办法,但我似乎无法找到任何至今。任何提示?

In application controller, but it doesn't seem to be working correctly. I still see my cookie after visiting any page. I feel like there really should be a better solution but I can't seem to find any so far. Any hints?

推荐答案

这似乎是一次我这样做,我只是改名会话密钥,以便新的AR存储会话并没有试图重新使用老cookie存储的cookie(这是有效地忽略前进)。

It seems like the one time I've done this that I simply renamed the session key so that the new AR store session did not try to re-use the old cookie store cookie (which was effectively ignored going forward).

这篇关于为ActiveRecordStore InvalidAuthenticityToken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆