I have a customer model, a merchant model and a transactions model. Customers can make transactions to merchants and merchants can make transactions to customers as well. Eventually, I'd like to query things like:
- All transactions made by a customer
- All transactions made by a merchant
- All of customer X's transactions to merchant Y (and vice versa)
- Optional: final all transactions with a certain tag first, and then find all associated merchants and customers related to those transactions. This is a nice-to-have feature, but if it's too complicated to explain in an answer then don't worry about it
So conceptually how should I create associations for each of these models? Like Customers has_many :merchants, through: :transactions (and vice versa)? or use polymorphic associations? etc etc.
Thanks a lot for your help!!!