Connecting Products to Cart
Let’s connect existing products to the cart.
We'll cover the following
We’re looking at sessions because we need somewhere to keep our shopping cart. We’ll cover sessions in more depth in a future chapter, but for now, let’s move on to implement the cart.
We’ll keep things simple. A cart contains a set of products. Based on the initial guess at the application data diagram combined with a brief chat with our customer, we can now generate the Rails models and populate the migrations to create the corresponding tables:
depot> bin/rails generate scaffold LineItem product:references cart:belongs_to
depot> bin/rails db:migrate
Get hands-on with 1400+ tech skills courses.