关闭导轨3中的CSRF令牌

| 我有一个Rails应用程序,可为iPhone应用程序提供一些API。 我希望能够简单地发布在资源上,而不必考虑获取正确的csrf令牌。 我尝试了一些我在stackoverflow中看到的方法,但似乎它们不再适用于rails 3。 感谢你们对我的帮助。     
已邀请:
在要禁用CSRF的控制器中,检查:
skip_before_action :verify_authenticity_token
或对除几种方法以外的所有功能禁用它:
skip_before_action :verify_authenticity_token, :except => [:update, :create]
或仅禁用指定的方法:
skip_before_action :verify_authenticity_token, :only => [:custom_auth, :update]
更多信息:RoR请求伪造保护     
在Rails3中,可以为特定方法禁用控制器中的csrf令牌:
protect_from_forgery :except => :create 
    
使用Rails 4,您现在可以选择以
skip_before_action
而不是
skip_before_filter
书写。
# Works in Rails 4 and 5
skip_before_action :verify_authenticity_token
要么
# Works in Rails 3 and 4 (deprecated in Rails 4 and removed in Rails 5)
skip_before_filter :verify_authenticity_token
    

要回复问题请先登录注册