Help with Ecto.Multi


I am attempting to use Ecto.multi for the first time to create related records. I have two tables, spot_conditions and spots. Spots belongs to spot_conditions. So i am trying to use ecto.multi to create both as following.

No spot is created, that is the output when trying to call the function. Not sure how to debug from here, any help would be greatly appreciated!

It looks like you are building the multi but not executing it. You just need to pass the finished multi into Repo.transaction in order to have it executed. Calling the multi functions themselves will just build up the commands you want to run but not actually execute them.

1 Like

That worked, thank you!!

Hey @chris-menz I’m glad the issue was solved! As a minor note, please copy and paste text in the future instead of using screenshots. It’s a lot more accessible to different screen sizes, and also makes it easier for people to suggest small edits by copying, pasting, and editing the code.