I'm having trouble deciding how to model the following with rails associations.
The UML would look something like below:
----------------
| CRITERIA |
----------------
|
|*
----------------
| CONTROLS | <___
---------------- \
^ \
| \
------------------- -------------------
| SCALE CONTROL | | TEXT CONTROL | .....
------------------- -------------------
-The various controls have quite different attributes so STI seems like a poor choice.
-A user can specify any number of controls per criteria.
I'd like to do something like the following:
Criteria
has_many :controls
ScaleControl
belongs_to :criteria, as: control
TextControl
belongs_to :criteria, as: control
And be able to query along the lines of:
criteria.controls
# displays all controls (text, scale, etc.)
criteria.controls.each { ... }
What I've looked at so far:
-RailsCasts' episodes on polymorphic associations and seems like this isn't a good use case.
-Dozens of rails associations posts on here but have failed to find anything directly relevant.
-Rails docs.
Are there any common patterns for implementing something like the above in Rails?