Phoenix error updating

Posted by / 21-Jun-2020 20:14

Phoenix error updating

Now that we have a working example, let’s clean up the code a bit.

Given this, I created a function that accepts a conn and the data Ecto returned, and returns a new conn.

My assumption here is that a database call that returns nil indicates a not found error.

So I use pattern matching to return either the :ok atom (200) or the :not_found atom (404).

If that use exists, we use the update changeset with Ecto update to perform the update. So we now have basic get, post and put endpoints that work.

We’ll now work to do some cleanup the code and return more useful error messages.

phoenix error updating-45phoenix error updating-63phoenix error updating-63

Here is a simple example of changeset for our user model.

One thought on “phoenix error updating”