質問編集履歴

2

情報の補足

2018/09/23 12:10

投稿

masa9216
masa9216

スコア15

test CHANGED
File without changes
test CHANGED
@@ -26,4 +26,78 @@
26
26
 
27
27
 
28
28
 
29
+
30
+
31
+ 以下、showアクションに対応するビューファイル
32
+
33
+
34
+
35
+ <div class="main posts-show">
36
+
37
+ <div class="container">
38
+
39
+ <div class="posts-show-item">
40
+
41
+ <div class="post-user-name">
42
+
43
+ <img src="<%= "/user_images/#{@user.image_name}" %>">
44
+
45
+ <%= link_to(@user.name, "/users/#{@user.id}") %>
46
+
47
+ </div>
48
+
49
+ <p>
50
+
51
+ <%= @post.content %>
52
+
53
+ </p>
54
+
55
+ <div class="post-time">
56
+
57
+ <%= @post.created_at %>
58
+
59
+ </div>
60
+
61
+ <% if Like.find_by(user_id: @current_user.id, post_id: @post.id) %>
62
+
63
+ <%= link_to("/likes/#{@post.id}/destroy", {method: "post"}) do %>
64
+
65
+ <span class="fa fa-heart like-btn-unlike"></span>
66
+
67
+ <% end %>
68
+
69
+ <% else %>
70
+
71
+ <%= link_to("/likes/#{@post.id}/create", {method: "post"}) do %>
72
+
73
+ <span class="fa fa-heart like-btn"></span>
74
+
75
+ <% end %>
76
+
77
+ <% end %>
78
+
79
+ <%= @likes_count %>
80
+
81
+
82
+
83
+ <% if @post.user_id == @current_user.id %>
84
+
85
+ <div class="post-menus">
86
+
87
+ <%= link_to("編集", "/posts/#{@post.id}/edit") %>
88
+
89
+ <%= link_to("削除", "/posts/#{@post.id}/destroy", {method: "post"}) %>
90
+
91
+ </div>
92
+
93
+ <% end %>
94
+
95
+ </div>
96
+
97
+ </div>
98
+
99
+ </div>
100
+
101
+
102
+
29
103
  よろしくお願いします。

1

質問箇所を太字に修正

2018/09/23 12:10

投稿

masa9216
masa9216

スコア15

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  @post = Post.find_by(id: params[:id])
4
4
 
5
- @user = @post.user
5
+ ** @user = @post.user**
6
6
 
7
7
  @likes_count = Like.where(post_id: @post.id).count
8
8