I have an array that contains some conditions, say:
ages = [1, 4, 10].
I am trying to build a query where it will return the ages in the array. The array can be of arbitrary length. So something like:
Person.where("age == :ages", {:ages => ages})
Now this obviously does not work as :ages would be an array, when according to the equality statement above, it's expecting a string.
I'm trying to have it achieve something along the lines of: WHERE age = 1 AND age = 4 AND age = 10 according to the ages array.
All examples online discuss how to use multiple where conditions when they are separate variables, in which case is easy as you would do: Person.where("condition1 = :first AND condition2 = :second....). I have unknown number of items in the array and I want to filter all my query result by them.