作者在 2023-07-05 16:49:17 发布以下内容
在 app/controllers/application_controller.rb 加入 “skip_before_action :verify_authenticity_token”,比如:
https://stackoverflow.com/a/5669355/873610
https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#method-i-skip_forgery_protection
class ApplicationController < ActionController::Base
include ApplicationHelper
skip_before_action :verify_authenticity_token # 就是加这行
before_action :check_login
# and so on ...............
end
参考:https://stackoverflow.com/a/5669355/873610
https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#method-i-skip_forgery_protection