I have a simple setup of Account and User :
class Account < ActiveRecord::Base
has_many :users
end
accounts
--------
id
name
...
.
class User < ActiveRecord::Base
belongs_to :account
end
users
-----
id
account_id
username
...
Now, how do I design that an Account has an “owner” (a user that has full privileges over the account). The options I can think of:
- Add a boolean field on User called
account_owner? (Does not feel right to me) - Add a field on
accountstable calleduser_id, thus creating a kind of chicken-and-egg problem. - Something else? Roles?
Would something like this work? You’d need to add an
owner_idforeign key toAccount.