Programming Phoenix LiveView: pg 222(epub) invalid association `product` in schema Pento.Survey.Rating: associated schema Product does not exist lib/pento/survey/rating.ex:1: Pento.Survey.Rating (module)

UPDATE: This was fixed by:

  • Deleting ratings table & rating.ex file

  • Re-running context gen command for Rating

  • Updating the schema in rating.ex to the following:

belongs_to: :user, Pento.Accounts.User
belongs_to: :product, Pento.Catalog.Product
  • Update changeset along with the book

  • Re-run mix ecto.migrate

  • Keep all other files i.e. demographics etc. the same

Now all associations are loaded in survey/query & product/query correctly.
I’m not sure why the association has to be explicit in this case, but I’m finally to be free from the roadblock - FYI if you happen to see anything like this in future, Sophie/Bruce and all other readers.