質問編集履歴
1
parameters: 内容の追記 共有箇所の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,6 +14,20 @@
|
|
14
14
|
|
15
15
|
undefined method `comments' for nil:NilClass
|
16
16
|
|
17
|
+
|
18
|
+
|
19
|
+
Parameters:
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
{"_method"=>"delete",
|
24
|
+
|
25
|
+
"authenticity_token"=>"rR7+250lRlmV7hN7/BluLRjYpZu6VV/GSa9NIg1FO4WOdEOXmd9FtvMumpLfaTZAZJoCk11SDk8oolc7lSna7g==",
|
26
|
+
|
27
|
+
"article_id"=>"1",
|
28
|
+
|
29
|
+
"id"=>"6"}
|
30
|
+
|
17
31
|
自分の理解がまだ薄くどのように解決したら良いか調べても答えが出ません。。
|
18
32
|
|
19
33
|
|
@@ -22,20 +36,54 @@
|
|
22
36
|
|
23
37
|
|
24
38
|
|
25
|
-
``
|
39
|
+
``
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
```ここに言語を入力
|
44
|
+
|
45
|
+
class CommentsController < ApplicationController
|
46
|
+
|
47
|
+
def create
|
48
|
+
|
49
|
+
# raise params.inspect
|
50
|
+
|
51
|
+
@article = Article.find params[:article_id]
|
52
|
+
|
53
|
+
@article.comments.create(comment_params)
|
54
|
+
|
55
|
+
redirect_to article_path(@article)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
def destroy
|
26
62
|
|
27
63
|
#raise params.inspect
|
28
64
|
|
29
65
|
@article = Article.find params[:article_id]
|
30
66
|
|
31
|
-
|
67
|
+
@comment = @aritcle.comments.find params[:id]
|
32
68
|
|
33
69
|
@comment.destroy
|
34
70
|
|
35
71
|
redirect_to article_path(@article)
|
36
72
|
|
37
|
-
end
|
73
|
+
end
|
38
74
|
|
75
|
+
|
39
76
|
|
77
|
+
def comment_params
|
78
|
+
|
79
|
+
params.require(:comment).permit(:commenter, :body)
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
40
84
|
|
41
85
|
```
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```
|