質問するログイン新規登録

回答編集履歴

1

内容の変更

2020/12/31 01:04

投稿

nasuk47
nasuk47

スコア311

answer CHANGED
@@ -1,7 +1,17 @@
1
1
  ```
2
+ def create
3
+ @diary = Diary.find(params[:diary_id])
4
+ @reply = Reply.new(reply_params)
5
+ if @reply.save!
6
+ redirect_to root_path
7
+ else
8
+ redirect_to root_path
9
+ end
10
+ end
11
+
12
+ private
13
+
2
14
  def reply_params
3
15
  params.require(:reply).permit(:reply_text).merge(user_id: current_user.id, diary_id: @diary.id)
4
16
  end
5
- ```
17
+ ```
6
-
7
- だとどうなるでしょうか?