4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails 5.2系 protect_from_forgery設定(csrfを対策を解除する)

4
Posted at

csrfを対策を解除する

5.2以前はprotect_from_forgery application_controller.rbに書いてあり、コメントアウトで解消していたが、5.2以降は以下の記述を追加することで、対応

application.rb
module TodoSample
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.2

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.

    # 以下の行を追加
    + config.action_controller.default_protect_from_forgery = false 
  end
end
4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?