LoginSignup
0
1

More than 5 years have passed since last update.

form_forからform_withってどう書き換えるの? (同時に2つのモデルを変更する場合 例:ネスト)

Posted at

答え

<%= form_for([@post.group, @post], local: true, url: choose_new_or_edit) do |f| %>
↓
<%= form_with(model:[@post.group, @post], local: true, url: choose_new_or_edit) do |f| %>

「model:」を付ける。

余談

「えっ!? forの方が短くていいじゃん」

<%= form_for([group, post, comment], remote: true) do |form| %>
↓
<%= form_with(model:[group, post, comment]) do |form| %>

「remote: true」を付けなくていい。

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