您的位置:首页 > 大数据 > 人工智能

Rails -- ActionController::InvalidAuthenticityToken解决办法

2015-11-11 14:27 519 查看
原文链接:http://cnkerry.iteye.com/blog/350718

解决方法一:

class FooController < ApplicationController
protect_from_forgery :except => :index

# you can disable csrf protection on controller-by-controller basis:
skip_before_filter :verify_authenticity_token
end


解决方法二:

修改config/environment/development.rb(或者production.rb)

# Disable request forgery protection in development environment
config.action_controller.allow_forgery_protection = false


然后重启服务器

解决方法三:

在jquery或者form中加入

<%= tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) %>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: