I'm building a multi-tenant rails app that is using a shared database where data is siloed by scoping everything to each account (similar to Basecamp 3)—rather than with separate tables and subdomains. The approach I'm taking is described here.
Each account will have its own data (e.g. products, inventory), and many users with different roles (e.g. account owner, employee, customer, etc.). I'm using Clearance for User signup and login.
It seems like there are two approaches that I could take with modeling an app like this:
- An account owner signs up and creates their account sorta like creating a profile. I'd create the account via nested fields on the sign up form. Everything inherits from the Account owner like this...

- Or, when a new user signs up a new Account is created and associated with that User (should this happen with a callback?). Everything (such as products and other users like employees or customers) inherit from the account, not the account owner. The account owner is just another User that belongs to the Account.

It seems like option 2 is the simpler solution, but I'm blocked on how to create the Account when a new user signs up via Clearance. I've gone into more detail on this problem here, but I'm worried that the way I'm modeling my app with Option 2 is not ideal.
Which one of these approaches is going to be simplest to setup and maintain? Or, is there another way to model this that I'm missing?
Because I'd eventually like the site to have some users that are customers, should I take the approach of using Subdomains (like Shopify?).
So, I'm not sure how well this solution will work as the app evolves over time, but I ended up going with this flow for now if it helps anyone else with a similar problem:
belong_toUser and every Userhas_oneAccountbelong_tothe Accountbelong_tothe AccountHere's a sketch of the relationships:
Here's the code:
accounts_controller.rb
models/account.rb
models/user.rb