如果我在表单中设置了remote: true,authenticity_token就会消失。我必须在我的表单中添加authenticity_token: true?那么缓存呢?如果我缓存表单,我必须添加authenticity_token: true?authenticity_token被缓存是一个问题吗?谢谢
发布于 2019-11-01 02:39:24
你在你的应用中使用jquery-rails gem吗?这将自动将CSRF令牌添加到remote: true AJAX表单提交:
https://github.com/rails/jquery-rails/blob/master/vendor/assets/javascripts/jquery_ujs.js#L69
// Make sure that every Ajax request sends the CSRF token
CSRFProtection: function(xhr) {
var token = rails.csrfToken();
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
}https://stackoverflow.com/questions/58644708
复制相似问题