Hey David, on the fifth beta and I’m a bit confused about setting up the model relationships:
On page 184, when setting up
customer.rb, I made the following corrections:
class Customer < ApplicationRecord has_many :customers_shipping_addressES #addresses as opposed to address def primary_shipping_address self.customers_shipping_addressES.find_by(primary: true).addressES #pluralized again end has_one :customers_billing_address has_one :billing_address, through: :customers_billing_addressES, source: :address #plural
Now with the original code, I tried calling the
primary_shipping_address method for my customer (id 350001, davetron5000), who has a shipping address associated with him, and also has an address created. I get
TypeError: superclass must be a Class (Module given).
Not sure how to proceed since
Customer.find_by(id: 350001).customers_shipping_addresses.find_by(primary: true) works, but not when I call
.address on it. The rest of my models have the same relationships as the ones on page 184 of the book.