質問編集履歴
1
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -183,4 +183,23 @@
|
|
183
183
|
{ id: 5, name: 'アジア、太平洋' }
|
184
184
|
]
|
185
185
|
end
|
186
|
+
```
|
187
|
+
|
188
|
+
酸味をlowに選択した時のパラメーターはこれです
|
189
|
+
```
|
190
|
+
[5] pry(#<DrinksController>)> params
|
191
|
+
=> <ActionController::Parameters {"q"=><ActionController::Parameters {"body_id_eq"=>"1", "acidity_id_eq"=>"2", "region_id_eq"=>"1", "processing_id_eq"=>"1"} permitted: false>, "commit"=>"検索", "controller"=>"drinks", "action"=>"search_drink"} permitted: false>
|
192
|
+
```
|
193
|
+
|
194
|
+
検索オブジェクト@pの結果はこれです
|
195
|
+
|
196
|
+
条件に一致する結果@resultsの配列は空でした
|
197
|
+
```
|
198
|
+
pry(#<DrinksController>)> @p
|
199
|
+
=> Ransack::Search<class: Drink, base: Grouping <conditions: [Condition <attributes: ["body_id"], predicate: eq, values: ["1"]>, Condition <attributes: ["acidity_id"], predicate: eq, values: ["2"]>, Condition <attributes: ["region_id"], predicate: eq, values: ["1"]>, Condition <attributes: ["processing_id"], predicate: eq, values: ["1"]>], combinator: and>>
|
200
|
+
[2] pry(#<DrinksController>)> @results
|
201
|
+
Drink Load (0.5ms) SELECT `drinks`.* FROM `drinks` WHERE (`drinks`.`body_id` = 1 AND `drinks`.`acidity_id` = 2 AND `drinks`.`region_id` = 1 AND `drinks`.`processing_id` = 1)
|
202
|
+
↳ app/controllers/drinks_controller.rb:52:in `search_drink'
|
203
|
+
=> []
|
204
|
+
|
186
205
|
```
|