質問編集履歴

3

タイトルの変更

2019/06/24 22:32

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- railsのdestroyがうまくいきません。
1
+ Railsのdestroyがうまくいきません。
test CHANGED
File without changes

2

説明不足

2019/06/24 22:32

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- HTMLとrouteは以下の通りです。
21
+ HTMLとrouteとcontrollerは以下の通りです。
22
22
 
23
23
 
24
24
 
@@ -45,6 +45,26 @@
45
45
  </div>
46
46
 
47
47
  <% end %>
48
+
49
+ ```
50
+
51
+
52
+
53
+ comments_controller.rb↓
54
+
55
+ ```ここに言語を入力
56
+
57
+ def destroy
58
+
59
+ @post = Post.find(params[:post_id])
60
+
61
+ @comment = @post.comments.find(params[:id])
62
+
63
+ @comment.destroy
64
+
65
+ redirect_to("/posts/#{@post.id}")
66
+
67
+ end
48
68
 
49
69
  ```
50
70
 
@@ -88,7 +108,7 @@
88
108
 
89
109
  PUT /posts/:post_id/comments/:id(.:format) comments#update
90
110
 
91
- DELETE /posts/:post_id/comments/:id(.:format) ←これがデストロイ comments#destroy
111
+ DELETE /posts/:post_id/comments/:id(.:format) comments#destroy
92
112
 
93
113
  posts GET /posts(.:format) posts#index
94
114
 

1

説明がわかりにくかった

2019/06/24 17:35

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -88,7 +88,7 @@
88
88
 
89
89
  PUT /posts/:post_id/comments/:id(.:format) comments#update
90
90
 
91
- DELETE /posts/:post_id/comments/:id(.:format) comments#destroy
91
+ DELETE /posts/:post_id/comments/:id(.:format) ←これがデストロイ comments#destroy
92
92
 
93
93
  posts GET /posts(.:format) posts#index
94
94