Two Different Types of Associatons on the Same Two Tables in Rails
- by tmo256
I have two models, users and themes, that I'm currently joining in a HABTM association in a themes_users table. Basically, after a user creates a new theme, it becomes available to other users to select for their own use.
However, only the original creator of the theme should have the ability to edit it. So, I need to have some other kind of association to handle that relationship, something like an created_by_id field in the theme.
In this way, the user model acts as two different roles: they can be an implementer of a theme AND/OR the owner of the theme. The implementer relationship is handled by the themes_users join table; the question is: What is the right way to handle this secondary association? Do I need to make users polymorphic and then make the created_by_id reference an "owner"? Or is there something easier?
Thanks so much for your help!