We've moved discussions to Discord

How to accept extra data upon user registration?

This is my first app working with associations between Users and Accounts and, after coming across this discussion and reading this section of the docs, I'm starting to get confused about how to add additional user information during registration with Devise.

Do we create a separate migration adding additional fields to the users table and permit the data through extra_keys in application_controller.html.erb? Do we somehow do this with accounts? The docs emphasize that the Personal Account is for resources accessible only to the User and does not mention anything about it being used for storing additional information.

Additionally, how can this information be extended for both regular user and admin registration?

Any guidance/clarification will be greatly appreciated. Thanks!

Chris Oliver
It's probably easiest if you add your own migration with the additional fields. You can edit the Jumpstart migration, but you may have to deal with merge conflicts if we change that in the template later. The separate migration is simplest in that case.

And yes, once you add the fields to the database, you add them to the ApplicationController permitted fields for Devise. That will make sure they get allowed when the user registers.

You can add fields to Account if you like, but it would be for things unique to each account (if the user has multiple). Address might be a good example that may fit best on an Account. I just released an update so you can enable the Account fields on registration automatically. Then you can add fields to Account and on the new user registration page.
Notifications
You’re not receiving notifications from this thread.