質問編集履歴
1
likesコントローラーの記述が漏れていたので追記させていただきました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -51,6 +51,28 @@
|
|
51
51
|
end
|
52
52
|
```
|
53
53
|
|
54
|
+
```likes_controller.rb
|
55
|
+
class LikesController < ApplicationController
|
56
|
+
|
57
|
+
before_action :post_params
|
58
|
+
|
59
|
+
def create
|
60
|
+
Like.create(user_id: current_user.id, post_id: params[:id])
|
61
|
+
end
|
62
|
+
|
63
|
+
def destroy
|
64
|
+
Like.find_by(user_id: current_user.id, post_id: params[:id]).destroy
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def post_params
|
70
|
+
@post = Post.find(params[:id])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
```
|
75
|
+
|
54
76
|
### 発生している問題・エラーメッセージ
|
55
77
|
ローカルサーバー上で出ているエラー文です
|
56
78
|
|