回答編集履歴
1
追記
test
CHANGED
@@ -19,3 +19,23 @@
|
|
19
19
|
どこか掲示するのを省略していませんか?
|
20
20
|
|
21
21
|
PostImagesController から一番下のpartialまで、関連するfileを全部、省略なしに見せてください。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
追記
|
26
|
+
|
27
|
+
indexに `<% @post_images.each do |post_image| %>` とあり、そのloopの中で`<%= render partial: 'post_images/post_images',` が実行されています。
|
28
|
+
|
29
|
+
で、そのpartialから _favorite.html.erb を呼んでいいねボタンを書いてますので、@post_imagesの数、つまりユーザの数だけ いいね がでてしまいます。
|
30
|
+
|
31
|
+
良いねを一つにしたいなら `<% @post_images.each do |post_image| %>` のloopの外に出すのですが、、、、
|
32
|
+
|
33
|
+
でも
|
34
|
+
|
35
|
+
これ、[**この人に**良いね」ですよね? ですからユーザごとに出て正解では?
|
36
|
+
|
37
|
+
問題は、「この人」がわからないこと。
|
38
|
+
|
39
|
+
`<%= render partial: 'post_images/post_images', collection: @post_images, as: :post_image %>`にて 一人ひとり書くところで @post_images 全体を渡しているのが問題です。
|
40
|
+
|
41
|
+
`<%= render partial: 'post_images/post_images', locals post_image: post_image %>`としてみてください。
|