回答編集履歴
1
情報追加
answer
CHANGED
@@ -4,4 +4,11 @@
|
|
4
4
|
@post = Post.new(parent_id: ペアレントのID)
|
5
5
|
で@postをつくっておけば
|
6
6
|
<% f.hidden_field :parent_id %>
|
7
|
-
で済みます。form_with @post だったっけ、、、
|
7
|
+
で済みます。form_with @post だったっけ、、、
|
8
|
+
#####
|
9
|
+
def new
|
10
|
+
@post = Post.new
|
11
|
+
end
|
12
|
+
ですと、
|
13
|
+
<% f.hidden_field :parent_id, @post.id %>
|
14
|
+
の @post.id は nil になりますよ
|