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

質問編集履歴

5

修正

2018/01/21 08:51

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -55,12 +55,20 @@
55
55
 
56
56
  ```
57
57
  # コメントに返信するフォーム(Posts/show)
58
+ - if @post.comments.present?
58
- - @post.comments.each do |comment|
59
+ - @post.comments.each do |comment|
60
+ p.commenter_name = comment.user.try(:name)
61
+ p.comment.content = comment.content
62
+ - comment.replies.each do |reply|
63
+ p.comment.content = reply.content
64
+
59
- = form_for [:reply, @post, comment], method: :post do |form|
65
+ = form_for [:reply, @post, comment], method: :post do |form|
60
- p
66
+ p
61
- = form.text_area :content, rows: 3, cols: 35, placeholder: "返信する"
67
+ = form.text_area "content", rows: 3, cols: 35
62
- p
68
+ p
63
- = form.submit "上記の内容で返信する"
69
+ = form.submit "上記の内容で返信する"
70
+
71
+ # ここの実装も良く分かりません。。。
64
72
  ```
65
73
 
66
74
 

4

修正

2018/01/21 08:51

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -54,7 +54,7 @@
54
54
  ```
55
55
 
56
56
  ```
57
- # コメントに返信するフォーム
57
+ # コメントに返信するフォーム(Posts/show)
58
58
  - @post.comments.each do |comment|
59
59
  = form_for [:reply, @post, comment], method: :post do |form|
60
60
  p

3

修正

2018/01/21 08:49

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -55,11 +55,12 @@
55
55
 
56
56
  ```
57
57
  # コメントに返信するフォーム
58
+ - @post.comments.each do |comment|
58
- = form_for [:reply, @post, comment], method: :post do |form|
59
+ = form_for [:reply, @post, comment], method: :post do |form|
59
- p
60
+ p
60
- = form.text_area :content, rows: 3, cols: 35, placeholder: "返信する"
61
+ = form.text_area :content, rows: 3, cols: 35, placeholder: "返信する"
61
- p
62
+ p
62
- = form.submit "上記の内容で返信する"
63
+ = form.submit "上記の内容で返信する"
63
64
  ```
64
65
 
65
66
 

2

追加

2018/01/19 04:03

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -53,6 +53,27 @@
53
53
 
54
54
  ```
55
55
 
56
+ ```
57
+ # コメントに返信するフォーム
58
+ = form_for [:reply, @post, comment], method: :post do |form|
59
+ p
60
+ = form.text_area :content, rows: 3, cols: 35, placeholder: "返信する"
61
+ p
62
+ = form.submit "上記の内容で返信する"
63
+ ```
56
64
 
57
65
 
66
+ ```
67
+ routes.rb
68
+
69
+ resources :posts do
70
+ resources :comments, only: [:create, :edit, :update, :destroy] do
71
+ member do
72
+ post :reply
73
+ end
74
+ end
75
+ end
76
+ ```
77
+
78
+
58
79
  アドバイスなど、よろしくお願いいたします!

1

修正

2018/01/19 04:02

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -46,6 +46,7 @@
46
46
  end
47
47
  end
48
48
 
49
+ # コメントに返信
49
50
  def reply
50
51
  # ここの実装がよく分かりません
51
52
  end