Ruby on Rails: 错误“ActionController::InvalidAuthenticityToken when disable JS/Ajax request”解决方案

来源:互联网 发布:国家网络信息安全举报 编辑:程序博客网 时间:2024/05/20 17:39
问题:在RoR项目中提交表格时出现:ActionController::InvalidAuthenticityToken when disable JS/Ajax request 的错误
解决方案:
在<form></form>中添加代码
<%= tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) %>
或,如果是建立的ruby格式的form input:使用:
<%= form_for @some_model, :remote => true, :authenticity_token => true do |f| %><% end %>
参考链接:
http://stackoverflow.com/questions/19452853/actioncontrollerinvalidauthenticitytoken-when-disable-js-ajax-request
0 0