gpt4 book ai didi

authentication - ActionController::InvalidAuthenticityToken 在 ActiveAdmin::Devise::SessionsController#create

转载 作者:行者123 更新时间:2023-12-05 06:27:58 25 4
gpt4 key购买 nike

我正在使用经过修改以启用 Active Admin 的 Ruby on Rails 5 Api 应用程序。到现在为止一切都很好。我不记得在应用程序中做过任何更改,但现在,如果我在浏览器上删除 cookies 等,我将无法登录到事件的管理应用程序,我得到的是这个错误:

enter image description here

我试图在应用程序 Controller 中添加这两个

protect_from_forgery :with => :exception

protect_from_forgery :with => :null_session

但没有一个有效。这是我的应用程序 Controller :

class ApplicationController < ActionController::Base
# protect_from_forgery :with => :exception
before_action :configure_permitted_parameters, if: :devise_controller?

protected
def configure_permitted_parameters
attributes = [:name]
devise_parameter_sanitizer.permit(:sign_up, keys: attributes)
end
end

我不知道是什么原因造成的,也不知道如何解决。提前致谢。

最佳答案

现在可以了。在我重新启动计算机并添加行后:

protect_from_forgery prepend: true, with: :exception

而不是在应用程序 Controller 中,它起作用了。

关于authentication - ActionController::InvalidAuthenticityToken 在 ActiveAdmin::Devise::SessionsController#create,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54804227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com