LoginSignup
0
0

More than 1 year has passed since last update.

RailsでPOSTしようとした時のActionController::InvalidAuthenticityTokenエラー

Posted at

Rails4 - 解決法

/app/assets/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  # protect_from_forgery with: :exception
end

protect_from_forgery with: :exception をコメントアウトする

Rails5.2以上 - 解決法1

/app/assets/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  skip_before_action :verify_authenticity_token, raise: false
end

skip_before_action :verify_authenticity_token, raise: false を追記する

Rails5.2以上 - 解決法2

/app/assets/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  protect_from_forgery
end

protect_from_forgery を追記する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0