September 2016
Intermediate to advanced
488 pages
12h 21m
English
At the moment, we have a few products, a few carts at any one time, and a few line items per cart or order, but we can have essentially an unlimited number of orders, and we hope to have many—enough so that displaying all of them on an orders page will quickly become unwieldy. Enter the kaminari plugin. This plugin extends Rails to provide this much-needed function.
Now let’s generate some test data. We could click repeatedly on the buttons we have, but computers are good at this. This isn’t exactly seed data, simply something done once and thrown away. Let’s create a file in the script directory:
| | Order.transaction do |
| | (1..100).each do |i| |
| | Order.create(name: "Customer #{i} |
Read now
Unlock full access