# Controller Function and Changeset for each attribute

**URL:** <https://forum.elixirforum.com/t/controller-function-and-changeset-for-each-attribute/31711>\
**Category:** Discussions\
**Tags:** ecto, phoenix, phx\_gen\_auth\
**Created:** [May 21, 2020, 5:27pm UTC](https://forum.elixirforum.com/t/controller-function-and-changeset-for-each-attribute/31711 "2020-05-21T17:27:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![peck](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peck/32/17928_2.png) [@peck](https://forum.elixirforum.com/u/peck)\
**Post date:** [May 21, 2020, 5:27pm UTC](https://forum.elixirforum.com/t/controller-function-and-changeset-for-each-attribute/31711/1 "2020-05-21T17:27:21Z")

</div>

I was taking a look at the new, and very welcome, gen\_auth ([GitHub - aaronrenner/phx\_gen\_auth: An authentication system generator for Phoenix 1.5 applications. · GitHub](https://github.com/aaronrenner/phx_gen_auth)). I’m excited that it is out there and it is going to do a lot of help people getting projects off the ground.

I did notice that the library does something a little differently than I have done before. There are different controller functions, and different change sets for each attribute. I found this interesting as I’m generally just had an `update` function in my controller that generated a single changeset to pass out to the eex forms [phx\_gen\_auth/priv/templates/phx.gen.auth/settings\_edit.html.eex at master · aaronrenner/phx\_gen\_auth · GitHub](https://github.com/aaronrenner/phx_gen_auth/blob/master/priv/templates/phx.gen.auth/settings_edit.html.eex).

I was wondering if this is something that you all do as well, or if @josevalim, @aaronrenner and the other library authors did it mostly for the explicitness and being able to do the flash messages. I’m adding this to one of my applications now, but my User has additional fields like an avatar, nickname, etc. I appreciate the explicitness but Im looking at all these other fields and Im thinking that I don’t really want to have a changeset/controller action for each one.

What approach do you all take?

---

<div class="post-metadata">

**Author:** ![josevalim](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/32/1787_2.png) [@josevalim](https://forum.elixirforum.com/u/josevalim)\
**Post date:** [May 21, 2020, 7:15pm UTC](https://forum.elixirforum.com/t/controller-function-and-changeset-for-each-attribute/31711/2 "2020-05-21T19:15:09Z")

</div>

> [@peck](#):
>
> my User has additional fields like an avatar, nickname, etc. I appreciate the explicitness but Im looking at all these other fields and Im thinking that I don’t really want to have a changeset/controller action for each one.
> 
> What approach do you all take?

You should create as many changesets as necessary but not more. The reason why email and password have their own changesets is because updating each of them has their own security requirements. But all other fields would be fine to be updated together. If your resource has the same fields on insert and update, then there is no need for two changesets either.
