My intention here was to change the deleted value to true in Chapter (deleting the chapter) and then change the value of deleted to true for all its Content with put_assoc by passing the original value mapped to replace deleted: false to true. Am I understanding it wrong?
This is wrong, sorry! It should be chapter.contents
This was the approach I adopted before, but the thing is, I didn’t want to lose these data for good so I’m not actually deleting these items from the database but only marking them as deleted and hiding it from the user (soft deletion), so what I need is really to just change those values!
You can implement this inner changeset any way you see fit (I’d recommend having it in your Content schema for consistency sake) but it’s important for the arity to be 2, even if you don’t use both:
def soft_deletion_changeset(content, _attrs) do
content
|> change(%{deleted: true})
end