About assoc

Hi,so i have a “groups” table,and I want to associate it with “products” table.

1 group can have multiple product.
others group also can have the same product.

I want to use one-to-many,since I dont need to query group from product.

if I use one-to-many, how to insert it to db?
can i just use build_assoc on the same product table for multiple group?

or maybe I should just use many-to-many?

I think you’ll want to make a join table and then a group has_many products through group_products.

2 Likes

thanks, this is what i need.