質問編集履歴
1
コントローラーを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -187,3 +187,45 @@
|
|
187
187
|
<%= f.submit "投稿する" %>
|
188
188
|
|
189
189
|
```
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
*articles_controllerを下記に追記します。
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
|
201
|
+
class ArticlesController < ApplicationController
|
202
|
+
|
203
|
+
before_action :set_article
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
def show
|
208
|
+
|
209
|
+
@comment = current_user.comments.build if signed_in?
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
private
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
def set_article
|
220
|
+
|
221
|
+
@article = Article.find(params[:id])
|
222
|
+
|
223
|
+
@comment = Comment.new
|
224
|
+
|
225
|
+
@comment.comment_images.new
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
```
|