HABTM, inside Cake ORM, is actually an abstraction of the following two model association structures (using your example):
Recipe -> hasMany IngredientsRecipe -> belongsTo Ingredient
and
Ingredient -> hasMany IngredientsRecipe -> belongsTo Recipe
The IngredientsRecipe model is inferred and used only to link the two first-class Ingredient and Recipe models.
However, in your case, you really want IngredientsRecipe be a first-class model, which violates the HABTM abstraction. In fact, you need to explicitly define the two relationship structures above, so Cake treats the IngredientsRecipe model as a first-class citizen, allowing you to query it, save records to it, etc.
Also, no, I donβt think it's too much to create an additional MeasurementUnit model. This will provide you with great flexibility along the line.
source share