'Add automatically new association to existing objects
I want to set-up a scorecard system base on criteria/sub-criteria pattern.
Given a Company(attrs: name) model, a Criteria(attrs: name) Model and a SubCriteria Model (attrs: name, score).
A Criteria has several SubCriterias,
For example: Advantage Criteria has SportClub subscription and Soccer ticket sub criterias.
I want for each existing companies in my DB (and future entries) to have automatically all these criterias and sub-criterias without duplicating everytime the sub-criteria.
I want at the end, to create a scorecard (like in the link au the beginning of the message) for every companies with score average on each criteria.
My question is : Is there any Rails relations to set-up to do it easily?
At the moment, i tried something like this:
Criteriahas_manySubCriteriasSubCriteriabelongs_toCriteriaCompanyhas_many_throughSubCriteriasSubCriteriahas_many_throughCompanies
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
