質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -85,3 +85,55 @@
|
|
85
85
|
end
|
86
86
|
|
87
87
|
```
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
```ここに言語を入力
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
ファイル名<comments.controller.rb>全ての記載
|
96
|
+
|
97
|
+
def create
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
@comment = Comment.create(text: comment_params[:text], tweet_id: comment_params[:tweet_id], user_id: current_user.id)
|
102
|
+
|
103
|
+
respond_to do |format|
|
104
|
+
|
105
|
+
format.html { redirect_to tweet_path(params[:tweet_id]) }
|
106
|
+
|
107
|
+
format.json
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
def destroy
|
116
|
+
|
117
|
+
comment = Comment.find(params[:id])
|
118
|
+
|
119
|
+
comment.destroy
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
def comment_params
|
130
|
+
|
131
|
+
params.require(:comment).permit(:text).merge(user_id: current_user.id, tweet_id: params[:tweet_id])
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
```
|