Rails, Can't verify CSRF token authenticity

I get

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):

when I try to use remote: true in a page with around 50 forms(If that matters, I don't get that problem anywhere else.)

There are many questions regarding the CSRF token. However, all solutions seem to stop my form from being remote. In other words, if I add

config.action_view.embed_authenticity_token_in_remote_forms = true

to my application.rb or

authenticity_token: true

or

= f.hidden_field :authenticity_token, value: form_authenticity_token

to my form, the object is created but rails tries to respond with html instead of with js. I also have the

= csrf_meta_tags

Any idea on how to fix that? Thank you in advance!

EDIT: The problem is that I submit the forms using js with form.submit().

链接地址: http://www.djcxy.com/p/81144.html

上一篇: InvalidAuthenticityToken,Ajax,带设备的Rails 5

下一篇: Rails,无法验证CSRF令牌的真实性