Using active record, how can I return the results for a model if they do not exist in a certain relationship elsewhere. For example, say I have a Recipe model which belongs to categories (via a category_recipes join table).
So basically I have a Rake task that looks through each recipe and it’s description and try to put in in a category, but the task takes a long time and I’ll need to run it on a regular basis, so I only want to run it if the Recipe in question has not already been categorized and I’d rather not add a superfluous column like categorized, so I figure there is a way to retrieve only the Recipes that don’t exist in the join table. Any thoughts?
Had to solve this myself today and think this will do the trick: