1
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?

More than 5 years have passed since last update.

編集フォームに変更する前の要素が入ってこないのをmodel,urlダブル指定で解決

Posted at

愚直すぎてこう考えつくまで時間がかかってしまった

失敗した方法

<%= link_to '編集', 'edit_board_path(@board)' %>

リンク先にローカル変数を送ってフォームで使わせるという方法
modelに@boardを当てるのと同じ効果があるらしいが自分の場合どこかおかしいみたいでうまくいかなかった。

<%= form_with  url: "/boards/#{@board.id}/edit", local: true do |f| %>

<%= form_with model: @board, local: true do |f| %>

modelやurlを片方でも置いとけば自動推測してくれるという言葉を鵜呑みにしたが動かなかった
あちらを立てればこちらが立たずを繰り返した

結局フォームにurlとmodelのダブル指定という形に落ち着いた

<%= form_with model: @board, url: "/boards/#{@board.id}/edit", local: true do |f| %>

なぜ動かなかったのか理由がわかれば更新せせてもらいます

今は代替案ということで

読んでくれてありがとう

1
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
1
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?