Say I have a Product table with a json array attribute called "name". For example, Product.first.name == ["large", "black", "hoodie"]
. I want to search through my database for Products with names that contain words in my search query. So if I type in "large hoodie", Product.first should be returned in the results.
So first I have to turn the search key into an array of strings:
def search
search_array = params[:search].split(" ")
results = #???
but how can I search for Products with names that include values also contained in search_array
? I've found documentation on how to search for values within arrays, but not on how to search for arrays themselves.