Here are the relevant models:
User
Product
Order
A User can sell or buy products
An order has a buyer, a seller and one product
I know that I can do this with a HABTM relationship between orders and user, but is seems to me like it would be simpler to put in the Order table the following columns:
:seller_id
:buyer_id
and manage those relationships manually as orders are only created once and never edited. However, this doesn’t seem very Rails-like and I am wondering if I am missing something conceptually at the HABTM relationship.
no it’s not a ruby way although you are not edited order once it created.
Use following relationship in model i think it will work. No check though