From 334054142cd444b1a79f00e587cbcd9d2f39eb8c Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 8 Sep 2015 12:45:11 +0200 Subject: [PATCH] add transactions method to user --- app/models/user.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 2b5a25d..cbc6d09 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,4 +16,8 @@ class User < ActiveRecord::Base class_name: 'Transaction', foreign_key: 'creditor_id' has_many :outgoing_transactions, class_name: 'Transaction', foreign_key: 'debtor_id' + + def transactions + Transaction.where("creditor_id = ? OR debtor_id = ?", id, id) + end end