回答編集履歴

3

追記

2020/01/25 11:07

投稿

winterboum
winterboum

スコア23364

test CHANGED
@@ -27,3 +27,13 @@
27
27
  not のを一つにまとめないでください。
28
28
 
29
29
  まとめると  『「両方を満足するもの」ではないもの』になってしまうので、片側だけ成立がhitしてしまいます。
30
+
31
+
32
+
33
+ 追記
34
+
35
+ 最後の .where(reactions: { status: [1,nil]}) は不要、有害かも
36
+
37
+ ReactionがないPhotoも有りますよね?それはhitして欲しい。。
38
+
39
+ だとすると、この最後の条件は外してください

2

1行削除

2020/01/25 11:07

投稿

winterboum
winterboum

スコア23364

test CHANGED
@@ -10,8 +10,6 @@
10
10
 
11
11
  @photos = photo.left_outer_joins(:reactions)
12
12
 
13
- .where.not(photos: { user_id: urrent_user.id}), # <= ) を追加した
14
-
15
13
  .where.not(id: ids).
16
14
 
17
15
  .where("reactions.from_user_id != ? or reactions.from_user_id is null",current_user.id)
@@ -20,6 +18,12 @@
20
18
 
21
19
  ```
22
20
 
21
+ from_userの記述がダブったので削除しました。
22
+
23
+ ので、このした2行は関係なくなりました
24
+
25
+
26
+
23
27
  not のを一つにまとめないでください。
24
28
 
25
29
  まとめると  『「両方を満足するもの」ではないもの』になってしまうので、片側だけ成立がhitしてしまいます。

1

typo修正

2020/01/25 11:04

投稿

winterboum
winterboum

スコア23364

test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  @photos = photo.left_outer_joins(:reactions)
12
12
 
13
- .where.not(photos: { user_id: urrent_user.id},
13
+ .where.not(photos: { user_id: urrent_user.id}), # <= ) を追加した
14
14
 
15
15
  .where.not(id: ids).
16
16