回答編集履歴
1
append
test
CHANGED
@@ -1 +1,57 @@
|
|
1
1
|
Controllerの`by_job`を呼び出している部分の動く場合とダメな場合のコードの追記をお願いします。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
たぶんControllerでは
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
|
15
|
+
@items = Item.by_job(params[:item][:by_job])
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
のように利用されているという仮定で進めますが、
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
|
27
|
+
scope :by_job, ->(input){
|
28
|
+
|
29
|
+
joins(:applicant_basic).where("job1 = ? or job2 = ? or job3 = ? or job4 = ? or job5 = ?",input,input,input,input,input)
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
を
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
|
43
|
+
scope :by_job, ->(input){
|
44
|
+
|
45
|
+
input = Array(input) # 配列でwrapする。すでに配列なら何も起こらない
|
46
|
+
|
47
|
+
joins(:applicant_basic)
|
48
|
+
|
49
|
+
.where("job1 IN (?) or job2 IN (?) or job3 IN (?) or job4 IN (?) or job5 IN (?)",input,input,input,input,input)
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
にしてみたらどうでしょうか。
|