I guess you could achieve this creating a scope that takes some args that you define in your Negotiation
model. I am not 100% on the correct syntax, but believe this approach is the most appropriate.
scope :seller_buyer_property_combo, ->(seller, buyer, property) {
where("negotiations.seller_id = ? AND
negotiations.buyer_id = ? AND
negotiations.property_id = ?", seller.id, buyer.id, property.id) }
This syntax follows the advice given here:
In Rails for example, the question mark is replaced by an argument given by a variable of the library's programming language (Ruby), e.g.:
Table.where("column = ?", "value")
and it automatically quotes arguments to avoid bugs and SQL injection, generating a statement like:
SELECT * FROM Table WHERE column = 'value';
The quoting would save us in case of something like:
Table.where("column = ?", "; INJECTION")
If you want to reuse the combinations and there are not so many perhaps you can just hard-code the combinations into a few different scopes (alleviating the needs for the args which may cause confusion in the ordering etc.)