質問編集履歴

1

likesコントローラーの記述が漏れていたので追記させていただきました。

2020/10/15 02:56

投稿

kotobuki562
kotobuki562

スコア0

test CHANGED
File without changes
test CHANGED
@@ -104,6 +104,50 @@
104
104
 
105
105
 
106
106
 
107
+ ```likes_controller.rb
108
+
109
+ class LikesController < ApplicationController
110
+
111
+
112
+
113
+ before_action :post_params
114
+
115
+
116
+
117
+ def create
118
+
119
+ Like.create(user_id: current_user.id, post_id: params[:id])
120
+
121
+ end
122
+
123
+
124
+
125
+ def destroy
126
+
127
+ Like.find_by(user_id: current_user.id, post_id: params[:id]).destroy
128
+
129
+ end
130
+
131
+
132
+
133
+ private
134
+
135
+
136
+
137
+ def post_params
138
+
139
+ @post = Post.find(params[:id])
140
+
141
+ end
142
+
143
+ end
144
+
145
+
146
+
147
+ ```
148
+
149
+
150
+
107
151
  ### 発生している問題・エラーメッセージ
108
152
 
109
153
  ローカルサーバー上で出ているエラー文です