teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

修正依頼があったため。

2020/02/07 06:04

投稿

yume0409
yume0409

スコア45

title CHANGED
File without changes
body CHANGED
@@ -37,5 +37,29 @@
37
37
  end
38
38
  end
39
39
  ```
40
+ destroy.html.haml
41
+ ```
42
+ .destroy
43
+ .destroy2
40
- 削除は実装しました
44
+ 削除できました
45
+ = link_to "戻る", "/", class: "destroy3"
46
+ ```
47
+ index.html.haml
48
+ ```
49
+ .chatmain
50
+ - @tweets.each do |tweet|
51
+ .tweets
52
+ .name
53
+ = tweet.user.name
54
+ .messa
41
- よろしくお願いします。
55
+ = tweet.text
56
+ = link_to "返信", "tweets/#{tweet.id}/comments", class: "comments"
57
+ - if user_signed_in? && current_user.id == tweet.user_id
58
+ = link_to "編集", "/tweets/#{tweet.id}/edit", method: :get, class: "edit"
59
+ = link_to "削除", "/tweets/#{tweet.id}", method: :delete, class: "delete"
60
+ .time
61
+ = tweet.created_at.strftime("%Y/%m/%d %H:%M")
62
+ .tweets2
63
+ = link_to new_tweet_path do
64
+ %i.fas.
65
+ ```

1

修正依頼があったため。

2020/02/07 06:04

投稿

yume0409
yume0409

スコア45

title CHANGED
File without changes
body CHANGED
@@ -26,4 +26,16 @@
26
26
  全て実装終わった時に変更しようと思っていますが、これが原因だったりしますでしょうか?
27
27
 
28
28
  かなり初歩的な質問ですが、ご回答頂けると助かります。
29
+ よろしくお願いします。
30
+
31
+ #補足
32
+ ```
33
+ def destroy
34
+ tweet = Tweet.find(params[:id])
35
+ if tweet.user_id == current_user.id
36
+ tweet.destroy
37
+ end
38
+ end
39
+ ```
40
+ 削除は実装しました。
29
41
  よろしくお願いします。