A score is calculated on create. It is not supposed to be recalculated in any other action, including :edit.
The following works on :create action, but not on the :edit action (because calculate_score/1 invokes Game.ScoreSystem.get_team!/1 which invokes Repo.get!(Team, id).
- What’s the correct way to use a different Changeset function on an
:editaction? e.g.,edit_action_changeset/2Do I simply invoke this function in the controller’s:editaction? How would I define that it’s an:editaction? - Or, how could I detect the Changeset action and ignore the
put_change/3function if it’s not a:createaction?
def changeset(team, attrs) do
team
|> put_change(:score, calculate_score(attrs["game_id"] || team.game_id))
end






















