From 13bf57d1323bee01931cb7fcc9b7e1be2a3acea3 Mon Sep 17 00:00:00 2001 From: Tom Naessens Date: Thu, 30 May 2019 21:39:53 +1200 Subject: [PATCH] Rails 5 has the relation now (closes #1) --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index c6fdc7f..53430f3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -32,7 +32,7 @@ class User < ActiveRecord::Base scope :humans, -> { where.not(id: self.zeus) } def transactions - Transaction.where("creditor_id = ? OR debtor_id = ?", id, id) + Transaction.where('creditor_id = ?', id).or(Transaction.where('debtor_id = ?', id)) end def calculate_balance!