March 2025
Intermediate to advanced
472 pages
12h 10m
English
An order is a set of line items, along with details of the purchase transaction. Our cart already contains line_items, so all we need to do is add an order_id column to the line_items table and create an orders table based on the Initial guess at application data diagram, combined with a brief chat with our customer.
First we create the order model and update the line_items table:
| | depot> bin/rails generate scaffold Order name address:text email \ |
| | pay_type:integer |
| | depot> bin/rails generate migration add_order_to_line_item order:references |
Note that we didn’t specify any data type for two of the four columns. This is because the data type defaults ...
Read now
Unlock full access