回答編集履歴
1
追記
test
CHANGED
@@ -15,3 +15,43 @@
|
|
15
15
|
@search_recipes = relation.result.page(params[:page]).per(8)`
|
16
16
|
|
17
17
|
で得ます
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
追記
|
22
|
+
|
23
|
+
`@categories = Category.where(ancestry: nil)
|
24
|
+
|
25
|
+
if params[:q].present?
|
26
|
+
|
27
|
+
else` の間を変えます。
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
@categories = Category.where(ancestry: nil)
|
32
|
+
|
33
|
+
@q = Recipe.ransack(params[:q])
|
34
|
+
|
35
|
+
if params[:q].present?
|
36
|
+
|
37
|
+
if t_b_m_m = params[:q].delete(:title_or_body_or_material_cont_any)
|
38
|
+
|
39
|
+
relation = Recipe.where()
|
40
|
+
|
41
|
+
# ここで t_b_m_m を使って relation = Recipe.where().where() という形を
|
42
|
+
|
43
|
+
# 組んでください。無論 scopeを使っても良いです。
|
44
|
+
|
45
|
+
else
|
46
|
+
|
47
|
+
relation = Recipe
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
@search = Rrelation.ransack(params[:q])
|
52
|
+
|
53
|
+
@search_recipes = @search.result.page(params[:page]).per(8)
|
54
|
+
|
55
|
+
else
|
56
|
+
|
57
|
+
```
|