The Placement Model

We need to set up the association between the order and the product with a has-many-to-many association. As each product can be placed in multiple orders and each order can have multiple products, we need a model that will join the two objects and map the appropriate association.

Generate the Placement model

Let’s generate the Placement model using this command in the terminal below:

$ rails generate model placement order:belongs_to product:belongs_to

Get hands-on with 1400+ tech skills courses.