messed-up habtm relationship

I think you may have confused what include? does.

The description (Ruby doc) is:

Returns true if any member of enum equals obj. Equality is tested using ==.

When testing your Ingredient objects for equality, unless you have specifically overridden == in your model, what's being compared to 'Chicken' is actually an object of type Ingredient.

Consider:

my_dish.ingredients.find{|ingredient| ingredient.name == 'Chicken'}

I'm pretty sure there's a better way to do this, but find is always reliable.

Hope this helps.

Keynan Pratt wrote: