DEV Community 👩‍💻👨‍💻

Discussion on: A Rails Multi-Tenant Strategy That's ~30 Lines and "Just Works"

Collapse
xhostcom profile image
Paul Anthony McGowan

One thing though if the new user has not signed up yet, can not set an account, or account_id, get error You must set an account with Current.account=

Needs workaround for that.

Collapse
codingbyharry profile image
Harry

Two possible options to consider:

  1. Create the tenant before the user so that the resource exists
  2. Don't use the concern on the user model and add a belongs_to :account, optional: true. Then probably want validations to ensure an account always exists on update.