Adding calculated field on save

defp fingerprint(changeset) do
    case changeset do
      %Ecto.Changeset{valid?: true, changes: %{address: address}} ->
        put_change(changeset, :fingerprint, create_fingerprint(address))
      _ ->
        changeset
    end
  end

Whoa. Mind blown. First off, thank you – this is way further than I would have gotten even after pouring over the Ecto docs. This code does execute, but the “fingerprint” value does not get set. I can test the create_fingerprint() function and verify that it returns a string value when given a map representing an address. I confess that I do not understand much of anything (including the syntax) of the defp fingerprint() function in your example. Can anyone walk me through that code? Or maybe someone can spot why that value isn’t persisting?

As always, many thanks.