简体   繁体   English

Rails会话第一次失败并通过重新加载

[英]Rails sessions fails first time and passes on reload

On login, and logout I end up getting this error when trying the first time. 在登录和注销时,第一次尝试时最终会收到此错误。 However, after refreshing it goes through. 但是,刷新后仍会通过。

"The change you wanted was rejected. Maybe you tried to change something you didn't have access to. If you are the application owner check the logs for more information." “您想要的更改被拒绝。也许您试图更改您无权访问的内容。如果您是应用程序所有者,请查看日志以获取更多信息。”

In my logs I get an ActionController::InvalidAuthenticityToken error so it has to be something with my sessions however I can't find anything to add. 在我的日志中,我收到一个ActionController :: InvalidAuthenticityToken错误,因此会话中一定有错误,但是找不到任何要添加的内容。

Are you using rails helpers to create the form? 您是否正在使用Rails助手来创建表单?

If not, you might need to add a CSRF token field. 如果不是,则可能需要添加CSRF令牌字段。 Using rail's form helper does it automatically for you. 使用rail的表单助手会自动为您完成。

Update: 更新:

Also check if your application controller has protect_from_forgery 还要检查您的应用程序控制器是否具有protect_from_forgery

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM