Phoenix error updating

Posted by / 13-Oct-2019 00:28

The insert function returns a tuple that indicates success or failure.

We use pattern matching to determine what HTTP status and data to render into JSON.

We now have a very simple REST API to create, read and update this simple user object.

I’ve purposely not performed any validation (other than uniqueness) on the model as I intend to use this in conjunction with an Elm front-end that performs validation.

Eventually I will add more validation and return that validation back to the Elm front end.

I found that creating the create (POST) and update (PUT) endpoints was relatively straightforward.

In the fail case, an Elixir map is returned with a list of error strings.

If you now use a REST client to perform put operations, you will see that valid data is properly written.

The only major difference is the separation of the changeset from the model.You can use the get endpoint to conform the proper writing of data.Our final major task will be to allow the update of existing records using a put endpoint. The put request received an additional parameter which contains the id of the record being updated.With this function in place, I then modify the two controller actions to add this transformation.Given that currently this function will only be used within this single controller, I made it a private function using the This allows the POST request to run, but nothing is written to the database yet.

phoenix error updating-58phoenix error updating-20phoenix error updating-26

Phoenix provides a function that adds the proper status code and returns a new conn with that status.

One thought on “phoenix error updating”

  1. He must have the following attributes- fun loving, I now have the time for myself (somewhat) and, after too many years, I'm looking to find my knight in shining armour.