I have a permissions model that is based on an individual Store. A store has a member that can view data has_and_belongs_to_many_users
, edit data has_and_belongs_to_many_editors
and own the Store has_and_belongs_to_many_owners
.
If I were to add more permissions in the future, I would have to add more joins. I'm not sure I like this model.
Store has_and_belongs_to_many_users
Store has_and_belongs_to_many_owners -> [Users]
Store has_and_belongs_to_many_editors -> [Users]
An alternative is this, I factor out the role, and create a second join table called "authorized users".
Here is what that could look like:
Store has_and_belongs_to_many_authorized_users
authorized_users: User_id Role_id
How can I use a second join table, that is called "authorized_users" with rails? Looking at my model, I do not have a model called authorized_users, and I am not sure how to build a model that relates to a join table.
essentially my question is, with Rails, How can I join a join table with a join table?