March 2025
Intermediate to advanced
472 pages
12h 10m
English
We’re looking at sessions because we need somewhere to keep our shopping cart. We’ll cover sessions in more depth in Rails Sessions, but for now let’s move on to implement the cart.
Let’s keep things simple. A cart contains a set of products. Based on the Initial guess at 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 |
| | == 20240610000003 CreateLineItems: migrating ================================== |
| | -- create_table(:line_items) ... |
Read now
Unlock full access