Hi! I'm modeling my application and i have a question about relationships:
I have 3 classes (tables): User (users), Company (companies) and Rol (rols)
The relationship between the 3 classes is another table that has:
Joining table X
Because a the same user can be in many companies. A company can have
many users. An a user have a single rol in a company but different
rols in another company.
So i can't name my table like users_companies because i have another
field, the rol_id so i should find another name, lets say X.
My model should be something like?:
class User < ActiveRecord::Base
has_many :companies, :through => X
class Company < ActiveRecord::Base
has_many :users, :through => X
class X < ActiveRecord::Base
And rol isn't a class because just have the type of user ("Admin", "Regular").
Is this ok? Is my first time doing this kind of relationship
Thanks in advance!