質問編集履歴

4

2020/12/21 03:25

投稿

MSSS.
MSSS.

スコア5

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- ある投稿(preschool)にネストしているコメント機能を非同期通信でコメントできるように
5
+ ある投稿にネストしているコメント機能を非同期通信でコメントできるように
6
6
 
7
7
  実装したいのですが、現状非同期にもならずハッシュで出されてしまっています。
8
8
 

3

Javaの中身を修正しています

2020/12/21 03:24

投稿

MSSS.
MSSS.

スコア5

test CHANGED
File without changes
test CHANGED
@@ -68,8 +68,6 @@
68
68
 
69
69
  }
70
70
 
71
- // const item = XHR.response.post;
72
-
73
71
  const list = document.getElementById("comment-list");
74
72
 
75
73
  const formText = document.getElementById("comment-content");

2

Javaの中身を修正しています

2020/12/21 03:23

投稿

MSSS.
MSSS.

スコア5

test CHANGED
File without changes
test CHANGED
@@ -33,68 +33,6 @@
33
33
 
34
34
 
35
35
 
36
-
37
- ↓preschoolの詳細画面(comment投稿画面)
38
-
39
-
40
-
41
- ```ruby
42
-
43
- <div class="preschool__comments">
44
-
45
- <% if user_signed_in? %>
46
-
47
- <%= form_with( model: [@preschool, @comment],id: "comment-form",local: true) do |f|%>
48
-
49
- <div class="field">
50
-
51
- <%= f.label :text, "ママ友の口コミ",id:"comment-content" %><br />
52
-
53
- <%= f.text_field :text %>
54
-
55
- </div>
56
-
57
- <div class="actions">
58
-
59
- <%= f.submit "送信する", class: :form__btn ,id:"submit" %>
60
-
61
- </div>
62
-
63
- <% end %>
64
-
65
- <% end%>
66
-
67
-
68
-
69
- <ul class="comments_lists" , id = "comment-list">
70
-
71
- <% @preschool.comments.each do |comment|%>
72
-
73
- <li class="comments_list">
74
-
75
- <%= comment.text%>
76
-
77
- <%= link_to "#{comment.user.nickname}さん", "/users/#{comment.user_id}",class: :comment_user %>
78
-
79
- </li>
80
-
81
- <% if user_signed_in? && current_user.id == comment.user_id %>
82
-
83
- <div class="comments_manage">
84
-
85
- <%= link_to "編集", edit_preschool_comment_path(comment.id), class: :comment_edit__btn %>
86
-
87
- <%= link_to "削除", preschool_comment_path(@preschool,comment), class: :comment_destroy_btn,method: :delete %>
88
-
89
- </div>
90
-
91
- <% end%>
92
-
93
- <% end %>
94
-
95
-
96
-
97
- ```
98
36
 
99
37
 
100
38
 
@@ -186,36 +124,6 @@
186
124
 
187
125
 
188
126
 
189
- ### 試したこと
190
-
191
- コントローラーのJsonが機能していないと思います。
192
-
193
-
194
-
195
- ```
196
-
197
- def create
198
-
199
- @comment = Comment.new(comment_params)
200
-
201
- render json:{ @comment :post}
202
-
203
- if @comment.save
204
-
205
- redirect_to preschool_path(@comment.preschool)
206
-
207
- else
208
-
209
- @preschool = @comment.preschool
210
-
211
- @comments = @preschool.comments
212
-
213
- render "preschools/show"
214
-
215
- end
216
-
217
- ```
218
-
219
127
 
220
128
 
221
129
  とすると文法のエラーになりました。。

1

画像が貼り付けられず、コードを書いています。

2020/12/21 03:21

投稿

MSSS.
MSSS.

スコア5

test CHANGED
File without changes
test CHANGED
@@ -12,11 +12,23 @@
12
12
 
13
13
 
14
14
 
15
+ 例:
16
+
15
- [![Image from Gyazo](https://i.gyazo.com/08ac088c7eea2e5c6e9fc730c590f8c2.png)](https://gyazo.com/08ac088c7eea2e5c6e9fc730c590f8c2)
17
+ aaaaというコメントを投稿した結果
18
+
19
+
20
+
16
-
21
+ ```
17
-
18
-
22
+
19
- [![Image from Gyazo](https://i.gyazo.com/e8ec1e48f53531a060516555d05f3003.png)](https://gyazo.com/e8ec1e48f53531a060516555d05f3003)
23
+ {"comment":{"id":81,"text":"aaaa","user_id":1,"preschool_id":5,"created_at":"2020-12-17T15:53:40.398+09:00","updated_at":"2020-12-17T15:53:40.398+09:00"}}
24
+
25
+ ```
26
+
27
+ というハッシュのみが画面遷移後表示される
28
+
29
+
30
+
31
+
20
32
 
21
33
 
22
34