So I have the Ninja model which has many Hovercrafts through
ninja_hovercrafts (which stores the ninja_id and the hovercraft_id).
It is of my understanding that this kind of arrangement should be set
in a way that the associative table stores only enough information to
bind two different classes.
But I’d like to use the associative table to work as a very
streamlined authorization hub on my application. So i’d also like this
table to inform my system if this binding makes the ninja the pilot or
co-pilot of a given hovercraft, through a “role” field in the table.
My questions are:
Is this ugly?
Is this normal?
Are there methods built into rails that would help me to automagically
create Ninjas and Hovercrafts associations WITH the role? For exemple,
could I have a nested form to create both ninjas and hcs in a way that
the role field in ninjas_hovercrafts would be also filled?
If managing my application roles this way isn’t a good idea, whats the
non-resource heavy alternative (my app is being designed trying to
avoid scalability problems such as excessive joins, includes, etc)
thank you