同样的接口请求,使用get工作正常。
使用post请求提示:
Can't verify CSRF token authenticity
在controller 中跳过验证
skip_before_action :verify_authenticity_token, :only => ["your_update_action"]
http://stackoverflow.com/questions/19390389/using-curl-to-access-backend-api-of-rails-app-that-implements-devise
如何通过post请求发送token验证?
Get does not verify csrf. Is your csrf_token placed in the request body?
Usually called in the layout file
<%= csrf_meta_tags %>
方法,并在js中引入jquery_ujs
For example
application.erb
application.js
Gemfile
Is it included in the form or added to the ajax request body? From your description, it should be that this csrf parameter is not added to the body of the post request