We've moved discussions to Discord

What's the proper/intended use of account and user models?

Brian Carpenter
Working on a music app for musicians to post tracks and songs.  If a "User" was in multiple bands, would/should the Account model represent each unique band which they could associate tracks to during an upload, or would it make more sense to create a  new "Bands" model which references User.   I get this could probably be done in a bunch of ways, but trying to stay within the intended framework of the template where possible and still unclear about how to think about User vs Account.
Jake Smith
If you have personal accounts enabled, there is an account with personal set to true created for that user.  Then that user is allowed to create non-personal accounts and invite others users to those non-personal accounts.  What is cool is that if you put a reference on your new model to Account (account_id), then you can do both.  So your personal accounts can have stuff saved that stays separate from what they contribute to any non-personal accounts they are associated with.

I've created a Folder/File directory structure for people to maintain somewhat of a mini file system as part of their collaborations, but without having to do anything other than associate Folder with Account, my personal account gets to have its own mini file system that the other accounts don't see, personal or not.  And the non-personal accounts get to have their own mini file systems too.
Jake Smith
This is what my folders migration looks like if that helps!

class CreateFolders < ActiveRecord::Migration[6.0]
  def change
    create_table :folders do |t|
      t.string :name
      t.references :account, null: false, foreign_key: true
      t.string :ancestry

      t.timestamps
    end
    add_index :folders, :ancestry
  end
end
Brian Carpenter
Thanks Jake, that's all helpful.  It looks like subscriptions are tied to the account so in addition to getting private/public containers, linking resources to the Account (vs User) will also provide some billing flexibility.  
Chris Oliver
I think Jake pretty much nailed it.

We wanted a way for you to share things between accounts, so having User separate from Account makes that a lot more flexible (and you can invite users to collaborate like in your case for a Band). That also makes it nice cuz billing can be separated out automatically for each account.

It's a tad more complex to start off with, but if you ever have to implement this yourself, you know it's a lot of work. And adding this functionality later is an absolute nightmare, so it's good to start with it in mind from the beginning I found.
Jake Smith
Amen, brotha'
Brian Carpenter
Thanks, makes sense, and rather useful now that I've got my head around it.
Notifications
You’re not receiving notifications from this thread.