I have 3 models in my test Rails 4 project.
- Company
- Project
- Contact
A Company has_many Contacts and has_many Projects. A Project belongs_to a Company. A Contact belongs_to a Company.
I want to be able to create a relationship between a Project and a Contact. There is the option to use the has_many :through relation but this will display all the Companies Contacts or Projects.
If I create a separate HABTM table i won't be able to use the "dependent: :destroy" option.
How can i make the relationship and let it be dependent on the company? So when i change the Contacts related company i won't have any corrupt data in my DB and all old relationships will be destroyed.