質問編集履歴
3
タイトルの変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
Railsのdestroyがうまくいきません。
|
body
CHANGED
File without changes
|
2
説明不足
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
どうすればidが渡ってくるようになるでしょうか?
|
10
10
|
|
11
|
-
HTMLとrouteは以下の通りです。
|
11
|
+
HTMLとrouteとcontrollerは以下の通りです。
|
12
12
|
|
13
13
|
show.html.erb↓
|
14
14
|
```ここに言語を入力
|
@@ -24,7 +24,17 @@
|
|
24
24
|
<% end %>
|
25
25
|
```
|
26
26
|
|
27
|
+
comments_controller.rb↓
|
28
|
+
```ここに言語を入力
|
29
|
+
def destroy
|
30
|
+
@post = Post.find(params[:post_id])
|
31
|
+
@comment = @post.comments.find(params[:id])
|
32
|
+
@comment.destroy
|
33
|
+
redirect_to("/posts/#{@post.id}")
|
34
|
+
end
|
35
|
+
```
|
27
36
|
|
37
|
+
|
28
38
|
route↓
|
29
39
|
```ここに言語を入力
|
30
40
|
cloud9user:~/environment/myapp (master) $ rails routes
|
@@ -43,7 +53,7 @@
|
|
43
53
|
post_comment GET /posts/:post_id/comments/:id(.:format) comments#show
|
44
54
|
PATCH /posts/:post_id/comments/:id(.:format) comments#update
|
45
55
|
PUT /posts/:post_id/comments/:id(.:format) comments#update
|
46
|
-
DELETE /posts/:post_id/comments/:id(.:format)
|
56
|
+
DELETE /posts/:post_id/comments/:id(.:format) comments#destroy
|
47
57
|
posts GET /posts(.:format) posts#index
|
48
58
|
POST /posts(.:format) posts#create
|
49
59
|
new_post GET /posts/new(.:format) posts#new
|
1
説明がわかりにくかった
title
CHANGED
File without changes
|
body
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
post_comment GET /posts/:post_id/comments/:id(.:format) comments#show
|
44
44
|
PATCH /posts/:post_id/comments/:id(.:format) comments#update
|
45
45
|
PUT /posts/:post_id/comments/:id(.:format) comments#update
|
46
|
-
DELETE /posts/:post_id/comments/:id(.:format)
|
46
|
+
DELETE /posts/:post_id/comments/:id(.:format) ←これがデストロイ comments#destroy
|
47
47
|
posts GET /posts(.:format) posts#index
|
48
48
|
POST /posts(.:format) posts#create
|
49
49
|
new_post GET /posts/new(.:format) posts#new
|