I receive an array of parameters from POST request, they look like the following:
Parameters:
{"search"=>
{ "minor"=>["1", "1"], "major"=>["1", "2"], "proximity_uuid"=>
["12345453453", "12345453453"]
}
}
which means I am requesting two items:
One with params:
minor: 1
major: 1
prox_uuid: 12345453453
and the second with:
minor: 1
major: 2
prox_uuid: 12345453453
As you may guess, I need to select items from DB that match exact these conditions.
I use the following query:
selectbeacon = Beacon.includes(:ads, :venue).where('minor IN (?)
and major IN (?) and proximity_uuid IN (?)', params[:search][:minor],
params[:search][:major], params[:search][:proximity_uuid])
However, the issue is that it selects all records that match at least one condition, but I need to match all three.
As the end result, I am generating complex JSON response.
How should I tweak my query?
thank you in advance,
Roman