質問編集履歴
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,14 +26,12 @@
|
|
26
26
|
|
27
27
|
### 該当のソースコード
|
28
28
|
|
29
|
-
|
29
|
+
|
30
|
-
|
30
|
+
|
31
|
-
likes_controller.rb
|
31
|
+
```ruby likes_controller.rb
|
32
32
|
|
33
33
|
class LikesController < ApplicationController
|
34
34
|
|
35
|
-
|
36
|
-
|
37
35
|
def create
|
38
36
|
|
39
37
|
@like = Like.create(user_id: current_user.id, post_id: params[:post_id])
|
@@ -60,11 +58,9 @@
|
|
60
58
|
|
61
59
|
end
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
```
|
66
|
-
|
62
|
+
|
67
|
-
model/like model
|
63
|
+
```ruby model/like model
|
68
64
|
|
69
65
|
class Like < ApplicationRecord
|
70
66
|
|
@@ -74,14 +70,14 @@
|
|
74
70
|
|
75
71
|
end
|
76
72
|
|
77
|
-
|
73
|
+
```
|
78
|
-
|
74
|
+
|
75
|
+
|
76
|
+
|
79
|
-
model/user model
|
77
|
+
```ruby model/user model
|
80
78
|
|
81
79
|
class User < ApplicationRecord
|
82
80
|
|
83
|
-
|
84
|
-
|
85
81
|
devise :database_authenticatable, :registerable,
|
86
82
|
|
87
83
|
:recoverable, :rememberable, :validatable
|
@@ -94,13 +90,15 @@
|
|
94
90
|
|
95
91
|
end
|
96
92
|
|
97
|
-
|
98
|
-
|
99
|
-
|
93
|
+
```
|
100
|
-
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
-
likes/_likes.html.erb
|
101
|
+
```ruby likes/_likes.html.erb
|
102
|
-
|
103
|
-
|
104
102
|
|
105
103
|
<% if user_signed_in? %>
|
106
104
|
|
@@ -146,9 +144,11 @@
|
|
146
144
|
|
147
145
|
<% end %>
|
148
146
|
|
149
|
-
|
147
|
+
```
|
150
|
-
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
-
posts/show.html.erb
|
151
|
+
```ruby posts/show.html.erb
|
152
152
|
|
153
153
|
<div class="id_page_button align-items-center mt-4 mb-4">
|
154
154
|
|
@@ -190,25 +190,25 @@
|
|
190
190
|
|
191
191
|
</div>
|
192
192
|
|
193
|
-
|
194
|
-
|
195
|
-
|
193
|
+
```
|
196
|
-
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
-
likes/create.js.erb
|
197
|
+
```js likes/create.js.erb
|
198
198
|
|
199
199
|
$("#like-buttons").html("<%= j(render partial: 'like', locals: { posts: @posts, likes: @likes, like: @like}) %>")
|
200
200
|
|
201
|
-
|
201
|
+
```
|
202
|
-
|
203
|
-
|
204
|
-
|
202
|
+
|
205
|
-
likes/destroy.js.erb
|
203
|
+
```js likes/destroy.js.erb
|
206
204
|
|
207
205
|
$("#like-buttons").html("<%= j(render partial: 'like', locals: { posts: @posts, likes: @likes, like: @like}) %>")
|
208
206
|
|
209
|
-
|
207
|
+
```
|
210
|
-
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
-
routes
|
211
|
+
```ruby routes.rb
|
212
212
|
|
213
213
|
Rails.application.routes.draw do
|
214
214
|
|
@@ -226,12 +226,6 @@
|
|
226
226
|
|
227
227
|
end
|
228
228
|
|
229
|
-
|
230
|
-
|
231
|
-
```ここに言語名を入力
|
232
|
-
|
233
|
-
ソースコード
|
234
|
-
|
235
229
|
```
|
236
230
|
|
237
231
|
|
@@ -246,8 +240,6 @@
|
|
246
240
|
|
247
241
|
### 補足情報(FW/ツールのバージョンなど)
|
248
242
|
|
249
|
-
rails
|
250
|
-
|
251
243
|
ruby 2.5.1
|
252
244
|
|
253
245
|
Rails 6.0.3.4
|
1
不要な部分があったので修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,14 +18,16 @@
|
|
18
18
|
|
19
19
|
```
|
20
20
|
|
21
|
-
エラーメッセージ
|
22
|
-
|
23
|
-
|
21
|
+
特になし
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
### 該当のソースコード
|
24
28
|
|
25
29
|
contlloer
|
26
30
|
|
27
|
-
### 該当のソースコード
|
28
|
-
|
29
31
|
likes_controller.rb
|
30
32
|
|
31
33
|
class LikesController < ApplicationController
|
@@ -78,9 +80,7 @@
|
|
78
80
|
|
79
81
|
class User < ApplicationRecord
|
80
82
|
|
81
|
-
|
83
|
+
|
82
|
-
|
83
|
-
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
84
84
|
|
85
85
|
devise :database_authenticatable, :registerable,
|
86
86
|
|