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

问题:在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

你可能感兴趣的:(Ruby on Rails: 错误“ActionController::InvalidAuthenticityToken when disable JS/Ajax request”解决方案)