The error occurs because the Tag
model does not have an association defined for tagged
.
To resolve this, you can either add a belongs_to :tagged
association in the Tag
model or explicitly reference the column name as the answer of @pungoyal:
tags = Tag.where(game_id: 1, tagged_id: u.id).includes(:tagged)