Invalid association: associated schema does not have field :id
When I came across this error it read in full:
invalid association `organization` in schema Barks.Team: associated schema Barks.Organization does not have field `id`
This was because I hadn’t updated what the new reference should be in my belongs_to
association after I switched from id to uuid for database primary keys.
My belongs_to
declaration looked like the below when it was erroing:
belongs_to :organization, Organization
But what I need was to explicitly call out the reference:
belongs_to :organization, Organization, references: :uuid
Similar posts: