我的<%= csrf_meta_tags %>
HEAD 标记中有 ,但我手动创建了表单,因此authenticity_token
隐藏字段没有插入到我的表单中。
所以我authenticity_token
手动添加了:
<input name="authenticity_token" value="<%= form_authenticity_token %>" type="hidden">
当我发送我网站的默认联系表单(用户未登录)时,处理它的操作应验证令牌并允许/拒绝请求。但事实并非如此:我使用 jQuery 清空字段并提交表单,但没有抛出错误或异常。
我得到了这一行protect_from_forgery with: :exception
并将application_controller.rb
其放入foo_controller.rb
扩展 application_controller 并具有响应联系表单的操作。
那么我错过了什么?我需要做什么才能在后端验证此表单?
非常感谢!