我正在 Rails 中构建一个 saas 引擎。我在 account#create 方法上遇到以下错误(使用了warden gem):
ActionController::InvalidAuthenticityToken in Subscribem::AccountsController#create
ActionController::InvalidAuthenticityToken
Rails.root: /home/jma/Documents/subscribem/spec/dummy
Application Trace | Framework Trace | Full Trace
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"x5sWQF8eRjwD/fcbdI+MJ1Y1gg7u2x7QvCoN3h1/1UM=",
"account"=>{"name"=>"test",
"subdomain"=>"test",
"owner_attributes"=>{"email"=>"jan@ma.de",
"password"=>"[FILTERED]",
"password_confirmation"=>"[FILTERED]"}},
"commit"=>"Create Account"}
我的应用程序控制器如下所示:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
当更改protect_from_forgery with: :exception
为 :null_session 时,错误消失了,但我认为这不是解决此问题的正确方法,因为用户应该在此注册操作后登录,而 :null_session 仅适用于 API。
该网站也没有为正在注册的用户创建任何似乎不正确的 cookie。
有任何想法吗?