Tag: forgery

Rails 3 protect_from_forgery无法正常工作?

我正在使用Rails 3.0.2,默认情况下在application_controller.rb中有protect_from_forgery 。 我想触发一个InvalidAuthenticityToken 。 要做到这一点,我已将此javascript添加到我的页面: $(‘input[name=authenticity_token]’).val(‘aaa’) 使用Firebug检查DOM我看到authenticity_token隐藏字段已正确更新。 如果我提交表单并从服务器检查日志,我会看到相对参数已正确设置为’aaa’。 我希望在处理请求时获得InvalidAuthenticityToken ,因为它是正确的! 这怎么可能?