0
0

method: deleteが効かない時の対処法

Last updated at Posted at 2024-08-22

はじめに

本質的な理解ではなく、あくまで対処法にとどまります。

対処法
@rails/ujsをyarn add -> install

問題

deviseを使って「ログアウト」を実装しようとしたところ、method: deleteを設定しているにも関わらず、getリクエストでページ遷移してしまい、該当のrouteは存在しないと言われる

対処法

method: deleteはJSライブラリによって管理されているようです。

今回は、JSライブラリ@rails/ujsを yarn add -> install で解決しました。

問題が解決しなかった理由

「rails立ち上げの際に esbuild を指定しているにも関わらず、importmap に関連した解決を試みたから」

本質的な理解ではありませんが、「esbuild」「webpacker」「importmap」が同じレベルのものらしいです。
よって、「importmap」と「esbuild」がコンフリクトを起こしてしまったのが問題を複雑にしていました。

rails 7 ではimportmapが標準、といった話を見た(勘違い?)のもこれに拍車をかけました。

おわりに

method: deleteはrailsの仕様なのだから、rails側で完結してくれよ・・・

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