Hi there, I was wondering if it’s feasible to store data in a model which is used for a
has_many :through association.
For example, I’ve got a User and an Advisor. I could, of course, add advisor_id to the User and use a regular has_many association in Advisor; however I’d also like to store metadata about this relationship such as what permissions the Advisor has over the User’s account.
I’m currently debating two ways of accomplishing this:
- Vanilla has_many - Simply add an advisor_id and permissions column to User and has_many :users to Advisor.
- has_many :through + serialized data - Create another model to store the user_id, advisor_id, and whatever metadata we decide to keep about this relationship. This would allow me to keep everything related to advisor/client relationships, which won’t apply to all users, contained within it’s own world.
I’d love some feedback on which approach is “right,” as I’m torn between the two.