add transactions method to user

This commit is contained in:
Ilion Beyst 2015-09-08 12:45:11 +02:00
parent 29a9af3cf0
commit 334054142c

View file

@ -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