Iteration G1: Capturing an Order
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 three out of the four columns. This is because the data type ...
Get Agile Web Development with Rails 5, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.