class ApplicationController < ActionController::Base
protect_from_forgery
end
rails2.0以后的版本都会默认开启该选项(在application_controller.rb中),它会利用保存在cookie中的 _csrf_token字段来生成自动添加在form中的隐藏字段_authenticity_token,然后利用 _authenticity_token来实现CSRF的功能。【摘自《关于rails中 cookie-session 和 protect_from_forgery 的理解 》http://blog.csdn.net/eyakcn/article/details/5476972】
protect_from_forgery 可以防止CSRF攻击,这个功能会在所有的表单中自动插入安全验证码.