I have a Map object with a 'cities' array field
class Map
include Mongoid::Document
field :cities, type: Array
end
I want to search for all the Map where at least one city is present from an other array. Something like this:
# map1.cities = ['London', 'Manchester']
# map2.cities = ['Paris', 'Lyon']
# map3.cities = ['Berlin', 'Munich']
# searchedCities = ['London', 'Paris']
I want all the maps that contains at least one of the searchedCities, in this case; map1 and map2.
This is not working, because it compares the whole array
Map.where(cities: searchedCities)
any ideas ?
Map.any_in(cities: searched_cities)