We've moved discussions to Discord

Issues using "Register with Account Details" for teams

Karl Bishop
I've switched on Include account fields in sign up / registration to let the first member of a team enter an Account Name and invite their colleagues to a shared account.

There are two scenarios I'm interested in:
  1. Team members all share a team account and each one has a personal account.
  2. Team members all share a team account and none of them has a personal account.

With the base code I can't quite achieve either scenario. I get the following results when testing:

Scenario 1

(Personal accounts are enabled)
  • First user signs up, entering the Account Name:
    • Account #1 is created and attached to this user ✔
    • But they do not have a personal account ❌
    • If this user tries to edit their username they hit an error:

NoMethodError in Users::RegistrationsController#update

undefined method `update' for nil:NilClass Extracted source (around line #36): # Sync the personal account name with the user's name personal_account.update(name: name) end end end app/models/concerns/user_accounts.rb:36:in `sync_personal_account_name' app/controllers/users/registrations_controller.rb:27:in `update_resource'

  • Second user is invited to Account #1 and signs up:
    • They are attached successfully to Account #1 ✔
    • And a personal account is created for them ✔

Scenario 2

(Personal accounts are disabled)
  • First user signs up, entering the Account Name:
    • Account #1 is created and attached to this user ✔
    • No additional accounts are created ✔
  • Second user is invited to Account #1 and signs up:
    • They are attached successfully to Account #1 ✔
    • But an additional private account is created for them ❌

I'm fairly new to Rails and am wondering, what is the simplest way to achieve my scenarios?

Specifically:
  • In Scenario 1, how could I ensure that both users are given their own Personal accounts (and avoid the error when the first user tries to edit their username)?
  • In Scenario 2, how could I prevent a second account being created when the second user signs up?

Any help much appreciated!
Karl Bishop
Scenario 2 question about avoiding an additional account being created for a second user is answered here:
Don't create accounts for invited users?


Notifications
You’re not receiving notifications from this thread.