Appendix 2Creating Customer Address Seed Data

This is the full listing for db/seeds.rb needed to create sample address data for all the fake customers we’ve been using to try out Postgres features. This is covered in Chapter 10, Cache Complex Queries Using Materialized Views. It’s included for completeness, but you may find it much easier to work with the source code, which you can download from the book’s website.[108]

Note that for this code to work, you’ll have to create the State, Address, CustomersBillingAddress, and CustomersShippingAddress models. You’ll also need to create necessary Active Record associations inside the Customer class. Although none of these are needed for Shine to function, they are for the seed data to work. Their ...

Get Rails, Angular, Postgres, and Bootstrap, 2nd 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.