简体   繁体   English

为什么我的表单的每个帖子都会收到 ActionController::InvalidAuthenticityToken?

[英]Why am I getting ActionController::InvalidAuthenticityToken with every post of my form?

We just rolled out an update to our app which switched to mem_cache_store for sessions.我们刚刚推出了对我们的应用程序的更新,它切换到 mem_cache_store 进行会话。 Immediately, all posts to forms threw an ActionController::InvalidAuthenticityToken exception.立即,forms 的所有帖子都引发了 ActionController::InvalidAuthenticityToken 异常。 I understand that there was a problem with this in 2.3.9, but we're on 2.3.10.我知道 2.3.9 中存在此问题,但我们使用的是 2.3.10。

The config change in production.rb is: production.rb 中的配置更改为:

require_library_or_gem 'memcache'

config.action_controller.session_store = :mem_cache_store
config.action_controller.session = {
  :secure => true,
  :cache => MemCache.new('our.memcache.host', :namespace => 'rack:session')
}

Am I doing something wrong?难道我做错了什么?

You need to rename the session key whenever you move the session store to prevent ActionController::InvalidAuthenticityToken errors.每次移动 session 存储时,都需要重命名 session 密钥,以防止出现 ActionController::InvalidAuthenticityToken 错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为我的XML获取一个ActionController :: InvalidAuthenticityToken - Getting an ActionController::InvalidAuthenticityToken for my XML 当我在form_for标记中使用collection_select时,ActionController :: InvalidAuthenticityToken - ActionController::InvalidAuthenticityToken when i am using collection_select in form_for tag 如何使用 Webpack 在 Rails 6 中提交 ajax 表格? 获取 ActionController::InvalidAuthenticityToken 错误 - How to submit ajax form in Rails 6 with Webpack? Getting ActionController::InvalidAuthenticityToken error Rails 5中的ActionController :: InvalidAuthenticityToken(仅发布) - ActionController::InvalidAuthenticityToken in Rails 5 with post only 删除表单Rails 4上的ActionController :: InvalidAuthenticityToken - ActionController::InvalidAuthenticityToken on delete form Rails 4 获取用于设计登录和注册的ActionController :: InvalidAuthenticityToken(ActionController :: InvalidAuthenticityToken)错误 - Getting ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken) error for devise sign in and sign up 为什么在我的控制器规格中出现ActionController :: UrlGenerationError:“没有路线匹配”? - Why am I getting ActionController::UrlGenerationError: “No route matches” in my controller spec? ActionController::InvalidAuthenticityToken - ActionController::InvalidAuthenticityToken ActionController :: InvalidAuthenticityToken:在表单上使用身份验证令牌进行验证 - ActionController::InvalidAuthenticityToken: verified with authentication token on the form 为什么会出现“ ActionController :: UrlGenerationError:路径不匹配…”错误? - Why am I getting an “ActionController::UrlGenerationError: No route matches…” error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM