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 9, Cache Complex Queries Using Materialized Views. It’s included for completeness, but you will find it much easier to work with the source code, which you can download from the book’s website.[120]

Also 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 ActiveRecord associations inside the Customer class. Although none of these are needed for Shine to function, they are for the seed data to work. ...

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