質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,6 +64,8 @@
|
|
64
64
|
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
65
65
|
|
66
66
|
</head>
|
67
|
+
|
68
|
+
|
67
69
|
```
|
68
70
|
```
|
69
71
|
webpack/enviroment.js
|
@@ -88,6 +90,67 @@
|
|
88
90
|
|
89
91
|
gem 'jquery-rails'
|
90
92
|
```
|
93
|
+
```
|
94
|
+
show.html
|
95
|
+
|
96
|
+
<div id="like_btn_<%= @post.id %>">
|
97
|
+
<%= render 'likes/like', post: @post %>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
<% if user_signed_in? && current_user.id == @post.user_id %>
|
101
|
+
<%= link_to '編集する', edit_post_path(@post.id) %><br>
|
102
|
+
<%= link_to '削除する', post_path(@post.id),method: :delete, "data-confirm"=>"本当に消しますか?" %><br>
|
103
|
+
<% end %>
|
104
|
+
|
105
|
+
<%= link_to '投稿一覧ページへ', posts_path %>
|
106
|
+
|
107
|
+
<div class="comment-wrapper">
|
108
|
+
<p>コメント件数:<%= @comments.count %></p>
|
109
|
+
<% if user_signed_in? %>
|
110
|
+
<%= form_with(model: [@post, @comment], local: true) do |f| %>
|
111
|
+
<%= f.text_area :content %>
|
112
|
+
<%= button_tag type: "submit" do %>
|
113
|
+
<i class="far fa-comments"></i> コメントする
|
114
|
+
<% end %>
|
115
|
+
<% end %>
|
116
|
+
<% end %>
|
117
|
+
<% @comments.each do |comment| %>
|
118
|
+
<div class="comments-index mb-2">
|
119
|
+
<%= comment.user.name %>
|
120
|
+
<%= comment.created_at.strftime("%Y-%m-%d %H:%M") %><br>
|
121
|
+
<%= comment.content %>
|
122
|
+
<div class="d-flex">
|
123
|
+
<% if comment.user == current_user %>
|
124
|
+
<div class="comment-delete">
|
125
|
+
<%= link_to "削除", post_comment_path(comment.post, comment), method: :delete, class: "btn-sm btn-danger" %>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
</div>
|
129
|
+
<% end %>
|
130
|
+
<% end %>
|
131
|
+
|
132
|
+
</div>
|
133
|
+
```
|
134
|
+
```
|
135
|
+
_like.html
|
136
|
+
|
137
|
+
<% if user_signed_in? %>
|
138
|
+
<% if current_user.already_liked?(post) %>
|
139
|
+
<%= link_to post_like_path(post), method: :delete, remote: true do %>
|
140
|
+
♥<%= @post.likes.count %> いいね
|
141
|
+
<% end %>
|
142
|
+
<% else %>
|
143
|
+
<%= link_to post_likes_path(post), method: :post, remote: true do %>
|
144
|
+
♡<%= @post.likes.count %> いいね
|
145
|
+
<% end %>
|
146
|
+
<% end %>
|
147
|
+
<% else %>
|
148
|
+
<i class="fas fa-heart"></i><%= post.likes.count %>
|
149
|
+
<% end %>
|
150
|
+
```
|
151
|
+
```
|
152
|
+
|
153
|
+
```
|
91
154
|
|
92
155
|
|
93
156
|
### 補足情報(FW/ツールのバージョンなど)
|