add transactions method to user
This commit is contained in:
parent
29a9af3cf0
commit
334054142c
1 changed files with 4 additions and 0 deletions
|
@ -16,4 +16,8 @@ class User < ActiveRecord::Base
|
||||||
class_name: 'Transaction', foreign_key: 'creditor_id'
|
class_name: 'Transaction', foreign_key: 'creditor_id'
|
||||||
has_many :outgoing_transactions,
|
has_many :outgoing_transactions,
|
||||||
class_name: 'Transaction', foreign_key: 'debtor_id'
|
class_name: 'Transaction', foreign_key: 'debtor_id'
|
||||||
|
|
||||||
|
def transactions
|
||||||
|
Transaction.where("creditor_id = ? OR debtor_id = ?", id, id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue