The example code to add a ratings association to the products schema is missing the direction to also add alias Pento.Survey.Rating
to the Pento.Catalog.Product
module.
With that alias missing the code doesn’t immediately get flagged as an error in the module but errors show up later when recompiling the project
warning: invalid association `ratings` in schema Pento.Catalog.Product: associated schema Rating does not exist
lib/pento/catalog/product.ex:1: Pento.Catalog.Product (module)
And when querying Catalog.list_products_with_user_ratings(user)
Pento.Catalog.Product does not have association or embed :ratings
Fixed block of code
alias Pento.Survey.Rating
schema "products" do
field :description, :string
field :name, :string
field :sku, :integer
field :unit_price, :float
field :image_upload, :string
has_many :ratings, Rating
timestamps()
end