Topic: The right way to handle a many-to-many modelling case
I have two models Product and Cart. The Cart has many products and the Products can also be seen to be contained in many Carts. I have used the has_and_belongs_to_many handler and have been able to achieve this relationship. However I have a field which says quantity (As in the quantity of the product that is being added to the cart); I do not know where to put this! In the Product? How will that work in many-to-many scenario.
In traditional modelling approaches, my table would have been:
carts_product with these details:
But now Rails handles all these with its ORM and Migrations; but how do I still get quantity to be unique to each Order/Product.
Any help is really appreciated