September 2016
Intermediate to advanced
488 pages
12h 21m
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 |
| | == CreateLineItems: migrating ================================================ |
| | -- create_table(:line_items) ... |
Read now
Unlock full access