This is being more difficult than I thought: I am building a system in which users can have two roles: Sellers and Buyers. The architecture must meet this requirements:
- A user must be at least one of them, or both. The most common case will of course be Buyer.
- Each user type has its own profile, with different sets of fields
- When a user registers, one of either profiles must also be created and associated to it.
- Users will have different actions available depending on their type of profile.
I have considered different design patterns but I am not good at databases design, so I am nit sure which one to apply or how. I’ve already discarded STI, so I think the solution must be some kind of user has_many :profiles & buyer/seller belongs_to :user. But I am not sure if I should use polymorphism, through, or other kind of relationship.
I’ve built some applications that have similar requirements. I believe the best solution that would meet your requirements is
has_many :through.Database: