Request Forgery Protection
protect_from_forgerybefore_action :verify_authenticity_tokenclass ApplicationController < ActionController::Base
protect_from_forgery
# 跳过 protect_from_forgery
skip_before_action :verify_authenticity_token, if: :json_request?
protected
def json_request?
request.format.json?
end
end最后更新于