質問編集履歴

2

ターミナルエラー表示追加

2021/02/14 11:36

投稿

0W5E8fPq1EOm4yE
0W5E8fPq1EOm4yE

スコア13

test CHANGED
File without changes
test CHANGED
@@ -6,9 +6,37 @@
6
6
 
7
7
  https://gyazo.com/7bb52e8a575e4e69ee8b1bccff26dce5
8
8
 
9
-
10
-
11
- POST http://localhost:3000/ways/8/likes 500 (Internal Server Error)
9
+ ```
10
+
11
+ ターミナル
12
+
13
+ ActionView::Template::Error (Missing partial likes/_way, application/_way with {:locale=>[:ja], :formats=>[:js, :html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder, :haml]}. Searched in:
14
+
15
+ * "/Users/nishio/projects/original/app/views"
16
+
17
+ * "/Users/nishio/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.3/app/views"
18
+
19
+ * "/Users/nishio/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actiontext-6.1.1/app/views"
20
+
21
+ * "/Users/nishio/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/actionmailbox-6.1.1/app/views"
22
+
23
+ ):
24
+
25
+ 1: $('#way_<%= @way.id %>').html("<%= j(render "way", post: @way) %>");
26
+
27
+
28
+
29
+ app/views/likes/create.js.erb:1
30
+
31
+ Started GET "/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDVG9JYTJWNVNTSWhaMncxZUdWaGRqTXhZVEV6TTNCdU1HRXlabTU0TW1KeVozUXhlUVk2QmtWVU9oQmthWE53YjNOcGRHbHZia2tpQWNacGJteHBibVU3SUdacGJHVnVZVzFsUFNJbE0wWWxNMFlsTTBZbE0wWWxNMFlsTTBZbE0wWWxNMFlsTTBZZ01qQXlNQzB4TWkweU1pQXlNQzQxTVM0ME55NXdibWNpT3lCbWFXeGxibUZ0WlNvOVZWUkdMVGduSnlWRk15VTRNaVZDT1NWRk15VTRNaVZCUmlWRk15VTRNeVZCUVNWRk15VTRNeVZDUXlWRk15VTRNeVZDTXlWRk15VTRNaVZDTnlWRk15VTRNeVZCTnlWRk15VTRNeVU0TXlWRk15VTRNeVU0T0NVeU1ESXdNakF0TVRJdE1qSWxNakF5TUM0MU1TNDBOeTV3Ym1jR093WlVPaEZqYjI1MFpXNTBYM1I1Y0dWSklnNXBiV0ZuWlM5d2JtY0dPd1pVT2hGelpYSjJhV05sWDI1aGJXVTZDbXh2WTJGcyIsImV4cCI6IjIwMjEtMDItMTRUMTE6Mzc6MzEuOTM1WiIsInB1ciI6ImJsb2Jfa2V5In19--1b2a0b8bdb3c3930c51acb9f96050a8036837a5c/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202020-12-22%2020.51.47.png" for ::1 at 2021-02-14 20:33:19 +0900
32
+
33
+ Processing by ActiveStorage::DiskController#show as PNG
34
+
35
+ Parameters: {"encoded_key"=>"[FILTERED]", "filename"=>"スクリーンショット 2020-12-22 20.51.47"}
36
+
37
+ Completed 200 OK in 1ms (ActiveRecord: 0.0ms | Allocations: 270)
38
+
39
+ ```
12
40
 
13
41
 
14
42
 

1

2/14現在のものに新しく変更した。

2021/02/14 11:36

投稿

0W5E8fPq1EOm4yE
0W5E8fPq1EOm4yE

スコア13

test CHANGED
File without changes
test CHANGED
@@ -4,23 +4,37 @@
4
4
 
5
5
  発生している問題・エラー
6
6
 
7
- https://gyazo.com/9f84ea915e7f1d9d4053994ecbd895e5
7
+ https://gyazo.com/7bb52e8a575e4e69ee8b1bccff26dce5
8
+
9
+
10
+
11
+ POST http://localhost:3000/ways/8/likes 500 (Internal Server Error)
8
12
 
9
13
 
10
14
 
11
15
  該当するソースコード
12
16
 
17
+ ```
18
+
13
19
  create.js.erb
14
20
 
15
21
 
16
22
 
17
- $('#<%= @way.id.to_s %>').html('<%= j render "ways/liked", { way: @way } %>');
23
+ $('#way_<%= @way.id %>').html("<%= j(render "way", post: @way) %>");
24
+
25
+ ```
26
+
27
+ ```
18
28
 
19
29
  destroy.js.erb
20
30
 
21
31
 
22
32
 
23
- $('#<%= @way.id.to_s %>').html('<%= j render "ways/liked", { way: @way } %>');
33
+ $('#way_<%= @way.id %>').html("<%= j(render "way", post: @way) %>");
34
+
35
+ ```
36
+
37
+ ```
24
38
 
25
39
  _like.html.erb
26
40
 
@@ -30,29 +44,27 @@
30
44
 
31
45
  <i class="btn btn-sm btn-outline-secondary">いいねを外す</i>
32
46
 
33
- <% end %>```
47
+ <% end %>
48
+
49
+ ```
34
50
 
35
51
  ```言語名
36
52
 
37
- _liked.html.erb
53
+ show.html.erb
38
-
39
-
40
-
41
- <%= link_to (way_like_path(@way.id, @way.liked_by(current_user)), method: :DELETE, remote: true, class: "liked") do %>
54
+
42
-
43
- <i class="btn btn-sm btn-outline-secondary">いいねを外す</i>
55
+
44
-
45
- <% end %>
46
56
 
47
57
  <%= render "devise/shared/header" %>
48
58
 
59
+ <body>
60
+
49
61
  <div class="col">
50
62
 
51
63
  <div class="card shadow-sm">
52
64
 
53
-
54
-
55
-
65
+
66
+
67
+
56
68
 
57
69
  <% if @way.image.attached? %>
58
70
 
@@ -68,13 +80,13 @@
68
80
 
69
81
 
70
82
 
71
-
83
+
72
84
 
73
85
  <div class="card-body">
74
86
 
75
87
  <div class="card-text">
76
88
 
77
- <%#= image_tag @way.user.image %><%= @way.user.nickname %>
89
+ <%= @way.user.nickname %>
78
90
 
79
91
  </div>
80
92
 
@@ -88,84 +100,76 @@
88
100
 
89
101
 
90
102
 
103
+ <tr>
104
+
105
+ <td>
106
+
91
- <div id="<%= @way.id.to_s %>">
107
+ <div id= "way_<%= @way.id %>">
92
-
108
+
93
- <% if @way.liked_by(current_user).present? %>
109
+ <%= render "way", post: @way %>
110
+
94
-
111
+ </div>
112
+
113
+ </td>
114
+
115
+ </tr>
116
+
117
+ </div>
118
+
119
+
120
+
95
- <%= link_to(way_like_path(@way.id, @way.liked_by(current_user)), method: :DELETE, remote: true, class: "liked") do %>
121
+ <div class="d-flex justify-content-between align-items-center">
96
-
122
+
97
- <i class="btn btn-sm btn-outline-secondary">いいねを外す</i>
123
+ <small class="text-muted"><%= l @way.created_at %></small>
124
+
98
-
125
+ <% if user_signed_in? && current_user.id == @way.user.id %>
126
+
127
+
128
+
129
+ <div class="btn-group">
130
+
131
+ <%= link_to '編集', edit_way_path, method: :get, class: "btn btn-sm btn-outline-secondary" %>
132
+
133
+ <%= link_to '削除', way_path, method: :delete, class:'btn btn-sm btn-outline-secondary' %>
134
+
135
+ </div>
136
+
99
- <% end %>
137
+ <% end %>
138
+
139
+ </div>
140
+
141
+ </div>
142
+
143
+ </div>
144
+
145
+
146
+
147
+ <div class="card-body">
148
+
149
+ <% if user_signed_in? && current_user.id != @way.user_id %>
150
+
151
+ <%= form_with model: [@way,@waycomment], local: true do |f|%>
152
+
153
+ <div class="field form-group">
154
+
155
+ <%= f.label :text, "コメント" %><br />
156
+
157
+ <%= f.text_field :text,id:"inputFile",class:"form-control" ,type:"text", id:"article_title",rows:"5" %>
158
+
159
+ </div>
160
+
161
+ <div class="actions text-right">
162
+
163
+ <%= f.submit "送信する", class:"btn-default red-round-btn" %>
164
+
165
+ </div>
166
+
167
+ <% end %>
100
168
 
101
169
  <% else %>
102
170
 
103
- <%= link_to(way_likes_path(@way), method: :POST, remote: true, class: "like") do %>
104
-
105
- <i class="btn btn-sm btn-outline-secondary">いいね</i>
106
-
107
- <% end %>
108
-
109
171
  <% end %>
110
172
 
111
- </div>
112
-
113
- </div>
114
-
115
-
116
-
117
- <div class="d-flex justify-content-between align-items-center">
118
-
119
- <small class="text-muted"><%= l @way.created_at %></small>
120
-
121
- <% if user_signed_in? && current_user.id == @way.user.id %>
122
-
123
-
124
-
125
- <div class="btn-group">
126
-
127
- <%= link_to '編集', edit_way_path, method: :get, class: "btn btn-sm btn-outline-secondary" %>
128
-
129
- <%= link_to '削除', way_path, method: :delete, class:'btn btn-sm btn-outline-secondary' %>
130
-
131
- </div>
132
-
133
- <% end %>
134
-
135
- </div>
136
-
137
- </div>
138
-
139
- </div>
140
-
141
-
142
-
143
- <div class="card-body">
144
-
145
- <% if user_signed_in? && current_user.id == @way.user_id %>
146
-
147
- <%= form_with model: [@way,@waycomment], local: true do |f|%>
148
-
149
- <div class="field form-group">
150
-
151
- <%= f.label :text, "コメント" %><br />
152
-
153
- <%= f.text_field :text,id:"inputFile",class:"form-control" ,type:"text", id:"article_title",rows:"5" %>
154
-
155
- </div>
156
-
157
- <div class="actions text-right">
158
-
159
- <%= f.submit "送信する", class:"btn-default red-round-btn" %>
160
-
161
- </div>
162
-
163
- <% end %>
164
-
165
- <% else %>
166
-
167
- <% end %>
168
-
169
173
  <%# // ログインしているユーザーには上記を表示する %>
170
174
 
171
175
  <ul class="comments_lists">
@@ -174,23 +178,29 @@
174
178
 
175
179
  <% @waycomments.each do |waycomment| %>
176
180
 
181
+ <% if @waycomments %>
182
+
177
183
  <li class="card-text">
178
184
 
179
-
180
-
185
+
186
+
181
- <%= @waycomment.text %>
187
+ <%= waycomment.text %>
182
188
 
183
189
  </li>
184
190
 
185
191
  <% end %>
186
192
 
193
+ <% end %>
194
+
187
195
  </div>
188
196
 
189
-
197
+ </body>
198
+
190
-
199
+ ```
200
+
201
+
202
+
191
-
203
+ ```
192
-
193
-
194
204
 
195
205
  class WaysController < ApplicationController
196
206
 
@@ -248,7 +258,7 @@
248
258
 
249
259
  @waycomment = Waycomment.new
250
260
 
251
- @waycomments = @way.waycomments.includes(:user)
261
+ @waycomments = @way.waycomments.includes(:user).order('created_at DESC')
252
262
 
253
263
  end
254
264
 
@@ -308,7 +318,9 @@
308
318
 
309
319
  end
310
320
 
311
-
321
+ ```
322
+
323
+ ```
312
324
 
313
325
  class LikesController < ApplicationController
314
326
 
@@ -348,6 +360,16 @@
348
360
 
349
361
  end
350
362
 
363
+
364
+
365
+ ```
366
+
351
367
  自分で試したこと
352
368
 
353
369
  ・link_toメソッドにremote: trueを追記。
370
+
371
+
372
+
373
+ ・下記のurlを参考にcreate.js.erbとdestory.js.erb2つのjs.erbファイルに$(console.log("111"));を記述してコンソール場にて確認後、発火したいクラスの記述を行った。
374
+
375
+ https://qiita.com/yoshi-2015/items/6d5eb88abb2a4ef09f92#%E3%81%84%E3%81%84%E3%81%AD%E6%A9%9F%E8%83%BD%E3%81%AE%E5%A0%B4%E5%90%88