0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

turbo効かなくて人生詰んだ

Last updated at Posted at 2025-11-26

問題となったコード

モーダルが動作していた頃のコード

モーダルが表示され、そこにnewアクションの内容が表示される

index.slim
= form_with model: @search do |f|
    = link_to("新規作成", new_user_path, data: { turbo_frame: "modal" })

モーダルが動作しなかったコード

モーダルが表示されず、ページ遷移してしまう

index.slim
= form_with model: @search, data: { turbo: false } do |f|
  = link_to("新規作成", new_user_path, data: { turbo_frame: "modal" })

解決方法

明示的に turbo: trueを link_toにつける

index.slim
= form_with model: @search, data: { turbo: false } do |f|
  = link_to("新規作成", new_user_path, data: { turbo_frame: "modal", turbo: true })

そもそもこのhtml構造が悪いとは思いますが、自分が実装してない箇所なんて気づけんよな

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?