I have task_lists and task_items tables. What I want is to cast data both through nested (in ListController/new) and non-nested (ItemController/new) forms.
The problem seems to be lying in Task.Item.changeset
def changeset(%Task.Item{} = item, attrs) do
item
|> cast(attrs, [:text, :list_id])
|> validate_required([:text, :list_id])
end
This way I can cast data through Task.ItemController/new with no problem. the foreign key is there to be saved.
However, I cannot cast data through Task.ListController/new unless I remove :list_id for cast_assoc in Task.Item.changeset already sets it up