# Elixir association help

**URL:** <https://forum.elixirforum.com/t/elixir-association-help/30794>\
**Category:** Discussions\
**Tags:** phoenix, associations\
**Created:** [April 20, 2020, 10:49pm UTC](https://forum.elixirforum.com/t/elixir-association-help/30794 "2020-04-20T22:49:17Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![nickdichev](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nickdichev/32/38172_2.png) [@nickdichev](https://forum.elixirforum.com/u/nickdichev)\
**Post date:** [April 21, 2020, 1:11am UTC](https://forum.elixirforum.com/t/elixir-association-help/30794/9 "2020-04-21T01:11:43Z")

</div>

So, in your controller you have `create/2` where you catch the happy path in the `with` clause. What I think is happening here is that you are actually getting a changeset error that isn’t being handled. The reason I think this is the case is because of the fallback controller function definition error.

You don’t have an `else` clause for the `with` so `create/2` is just returning the `{:error, changeset}` of `Repo.insert()` in `create_image/1`. But, `{:error, changeset}` isn’t a valid `%Plug.Conn{}` struct – the expected return of your controller functions!

Since you’re not returning a `%Plug.Conn{}`, Phoenix tries to help you out and call your defined fallback controller `ApiAppWeb.FallbackController`. You are likely missing the function `call(conn, {:error, changeset})` there (you might want to pattern match against the changeset against `%Ecto.Changeset{}` to avoid a catch all match…)

So you have a couple options to debug from here. You can define the fallback controller `call/2` and inspect in there, or put an inspect in your changeset pipeline to see what’s going wrong. (The error is actually in the previous error you posted, at the very end of the line)

I know this is a lot so let me know if you have any questions! Also [here’s the documentation](https://hexdocs.pm/phoenix/Phoenix.Controller.html#action_fallback/1) on the fallback controller with good examples!

---

_[View the full topic](https://forum.elixirforum.com/t/elixir-association-help/30794)._
