So I have a recipes table and an ingredients table. In the recipes table there is an ingredient column that is an array listing the ids of all the ingredients necessary for each recipe.
I want to search through that array to find if it contains one particular ingredient.
I found the include?
method which works great in a case like :
Recipe.find(35).ingredient.include? params[:ingredient]
I'm trying to make that work with a where method to get something like this :
Recipe.where('ingredient.include?', params[:ingredient].to_i)
It seems pretty straightforward but it doesn't work. I tried removing the comma, same result.
I can't figure out the proper syntax for it to work.