質問編集履歴
2
背景を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,6 +22,42 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
+
## 背景
|
26
|
+
|
27
|
+
AdtiveAdminのfilterで以下のようにして、Elasticsearchを利用したい。
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
|
33
|
+
## models/product.rb
|
34
|
+
|
35
|
+
scope :keyword_search, -> (search) {
|
36
|
+
|
37
|
+
Product.search(search).records.records
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
def self.ransackable_scopes(_auth_object = nil)
|
42
|
+
|
43
|
+
%i(keyword_search)
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
## admin/product.rb
|
50
|
+
|
51
|
+
ActiveAdmin.register Project do
|
52
|
+
|
53
|
+
filter :keyword_search, as: :string
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
|
25
61
|
## versions
|
26
62
|
|
27
63
|
rails (4.2.5.1)
|
1
Rails初心者のため、初心者マークを追加
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|