信頼性トークンをチェックしたくない特定のアクションがある場合、そのチェックをスキップするように Rails に指示するにはどうすればよいですか?
ベストアンサー1
Rails 5.2以上
同じものを使うことができますskip_before_action
以下に挙げた方法、または新しい方法skip_forgery_protection
(薄いラッパー)skip_before_action :verify_authenticity_token
skip_forgery_protection
Rails 4+:
# entire controller
skip_before_action :verify_authenticity_token
# all actions except for :create, :update, :destroy
skip_before_action :verify_authenticity_token, except: [:create, :destroy]
# only specified actions - :create, :update, :destroy
skip_before_action :verify_authenticity_token, only: [:create, :destroy]
すべてのオプションについては、api.rubyonrails.org をご覧ください。
Rails 3以下:
skip_before_filter :verify_authenticity_token