Iteration E1: Creating a Smarter Cart
Associating a count with each product in our cart is going to require us to modify the line_items table. Weâve used migrations before; for example, we used a migration in âApplying the Migrationâ to update the schema of the database. While that was as part of creating the initial scaffolding for a model, the basic approach is the same:
â | âdepot>ââ ââbin/railsââ ââgenerateââ ââmigrationââ ââadd_quantity_to_line_itemsââ ââquantity:integerâ |
Rails can tell from the name of the migration that youâre adding columns to the line_items table and can pick up the names and data types for each column from the last argument. The two patterns that Rails matches on ...
Get Agile Web Development with Rails 5, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.