回答編集履歴
2
言葉遣いの修正
answer
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
やりたいことは、
|
2
2
|
|
3
3
|
microposts/index.html.haml
|
4
|
-
|
4
|
+
ーーーーーーーーー
|
5
5
|
|ポスト1 [いいね!]|
|
6
6
|
|ポスト2 [いいね!]|
|
7
7
|
|ポスト3 [いいね!]|
|
8
|
-
|
8
|
+
ーーーーーーーーー
|
9
9
|
|
10
10
|
のような一覧画面を作りたいということであっていますか?
|
11
11
|
であれば、質問者さんが挙げられているhttps://qiita.com/mikan3rd/items/21d716026b51331e53a1こちらのページがまさにそれをやっています。
|
12
12
|
|
13
|
-
具体的には、下記のよう
|
13
|
+
具体的には、下記のように書けばできると思います。
|
14
14
|
|
15
15
|
```ruby
|
16
16
|
#views/microposts/index.html.haml
|
1
誤字修正
answer
CHANGED
@@ -27,14 +27,14 @@
|
|
27
27
|
```ruby
|
28
28
|
#views/likes/_like_links.html.haml
|
29
29
|
#いいねボタン
|
30
|
-
if current_user.likes.find_by(
|
30
|
+
if current_user.likes.find_by(micropost_id: micropost.id)
|
31
|
-
= link_to unlike_path(
|
31
|
+
= link_to unlike_path(micropost.id), method: :delete, remote: true do
|
32
|
-
.btn.btn-default.glyphicon.glyphicon-heart{id: "heart-#{
|
32
|
+
.btn.btn-default.glyphicon.glyphicon-heart{id: "heart-#{micropost.id}"}
|
33
|
-
=
|
33
|
+
= micropost.likes.count.to_s
|
34
34
|
- else
|
35
|
-
= link_to like_path(
|
35
|
+
= link_to like_path(micropost.id), method: :post, remote: true do
|
36
|
-
.btn.btn-default.glyphicon.glyphicon-heart-empty{id: "heart-#{
|
36
|
+
.btn.btn-default.glyphicon.glyphicon-heart-empty{id: "heart-#{micropost.id}"}
|
37
|
-
=
|
37
|
+
= micropost.likes.count.to_s
|
38
38
|
```
|
39
39
|
|
40
40
|
的外れでしたらすみませんm(_ _)m
|