I have a problem with a relationship that I dont how exactly to code. I been looking at the rails guide but no luck.
I have 3 Models: User, Owner and Company.
-
User belongs_to Company / Company has_many Users
-
Company belongs_to Owner / Owner has_one Company
The problem is the next: User and Owner are the same models, I now it is possible that two different classes use the same Model. But I don’t know how to do that. Could someone give me a hand with these? Thanks in advance.
You can define associations like this:
If your company table has column call owner_id, define this:
If your company table has column call user_id, define this: