Reputation: 2501
I have a recipe which has many ingredients. An ingredient has many tastes. I would like to get all of the Recipes that do not have ingredients that have a certain taste.
One query would be for all recipes that do not have ingredients with the taste "spicey"
I was able to get all of the recipes with the ingredient "bread" using
Recipe.includes(:ingredients).where('ingredients.name = ?', 'bread').references(:ingredient)
But I can't seem to get that next level filter.
Please advise. Thank you!
Upvotes: 1
Views: 34
Reputation: 339
Perhaps you could try
Recipe.includes(:ingredients).where.not('ingredients.name = ?', 'bread')
Upvotes: -1