第一种: 

Ror代码

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  

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\environments\development.rb 

 
 

 
 

Ror代码

# Disable request forgery protection in development environment  

   config.action_controller.allow_forgery_protection = false  

 
 

然后重启服务器 

 
 

 
 

第三种: 

在jquery或form中加入 

Ruby代码

<%= tag(:input, :type => "hidden", :name =>   

request_forgery_protection_token.to_s, :value =>   

form_authenticity_token) %> 

 
 

来自 <http://blog.csdn.net/iam_song/article/details/7688631>

ActionController::InvalidAuthenticityToken 解决办法(第二种尤其有效)的更多相关文章

  1. rails中ActionController::InvalidAuthenticityToken解决办法

    Ror代码 class FooController < ApplicationController protect_from_forgery :except => :index # you ...

  2. ruby -- 问题解决(七)ActionController::InvalidAuthenticityToken解决办法

    学习链接:http://cnkerry.iteye.com/blog/350718 解决方法一: class FooController < ApplicationController prot ...

  3. SqlServer数据库(可疑)解决办法4种

     亲自试过,可行!!!!! SqlServer数据库(可疑)解决办法4种   重启服务--------------------------------------------------日志文件丢了, ...

  4. Mybatis传递多个参数的解决办法(三种)

    第一种方案 DAO层的函数方法 Public User selectUser(String name,String area); 对应的Mapper.xml <select id="s ...

  5. ANDROID STDUIO 项目里的R文件突然丢失的解决办法N种之一

    刚刚项目里的R文件突然挂了,清理项目,关闭重开Studio,都不能解决.快没折了. 然后只好在项目上右击,看看有没有解决的办法.发现有个 Make Module ,姑且试试吧. 结果,竟然修复了.这是 ...

  6. Bootstrap中关闭第二个模态框时出现的问题和解决办法

    Bootstrap中关闭第二个模态框时出现的问题和解决办法 1.关闭第二个模态框时,第一个模态框跟着消失. 解决办法: 第二个模态框的代码不要写在第一个模态框里面,确保两个模态框相对独立; 2.关闭第 ...

  7. IIS服务器应用程序不可用的解决办法

    转载:http://www.cnblogs.com/caicainiao/archive/2010/11/29/1891085.html 这个问题见了好几次,在.net下 Microsoft visu ...

  8. 关于github在mac 10.10上无法提交代码的解决办法---备用

    接下来是正文:本文主要说明在mac 10.10版本下github无法提交代码的问题 首先如果你是一个用终端提交代码的,你可以不用看这篇文章了,这篇文章主要是用于解决github客户端提交代码的问题,此 ...

  9. 解决办法:CMake编译时出现“error in configuration process project files may be invalid”

    无论是CMake2.84 还是当前最新的CMake2.87都可能会出现这种错: 查遍国内外的网上都没有给出可行办法,结果还是自己解决了 现把出错原因和解决办法如下:出错原因:因是英文版本,通常安装没有 ...

随机推荐

  1. 将对象转换成Dictionary 字典

    /// <summary> /// /// 将对象属性转换为key-value对 /// </summary> /// <param name="o" ...

  2. 非Controller类无法使用Service bean解决方案

      尝试方案: 1 在Spring的配置文件springmvc.xml中,增加扫描项base-package="zxs.ssm.util",增加你需要使用service的类所在的包 ...

  3. php---初学者git使用

    1.git自学网站 廖雪峰的官方网站 2.安装一个简单的git 创建用户名.邮箱 git config --global user.name "your name" git con ...

  4. 安装PHPStudy2014,打开端口出现80端口 PID4 进程:System-windows服务器应用

    原文:安装PHPStudy2014,打开端口出现80端口 PID4 进程:System-windows服务器应用-黑吧安全网 安装PHPStudy2014,打开端口出现80端口 PID4 进程:Sys ...

  5. [LeetCode]题解(python):111 Minimum Depth of Binary Tree

    题目来源 https://leetcode.com/problems/minimum-depth-of-binary-tree/ Given a binary tree, find its minim ...

  6. [LeetCode]题解(python):092 Reverse Linked List II

    题目来源 https://leetcode.com/problems/reverse-linked-list-ii/ Reverse a linked list from position m to  ...

  7. [LeetCode]题解(python):074-Search a 2D Matrix

    题目来源 https://leetcode.com/problems/search-a-2d-matrix/ Write an efficient algorithm that searches fo ...

  8. 10 Golden Rules of Project Risk Management

    The benefits of risk management in projects are huge. You can gain a lot of money if you deal with u ...

  9. linux matlab2013b 安装教程

    链接:http://pan.baidu.com/s/1pJE6R2b 密码:shfy 1. 解压缩“Mathworks Matlab R2013b Linux.rar”(无需密码),得到“Mathwo ...

  10. 苹果公司给出的检测 advertisingIdentifier 的方法

    To locate the reference to the advertisingIdentifier selector, please perform these steps to create ...