В транзакции:
belongs_to :lender, :class_name => "User"
belongs_to :borrower, :class_name => "User"
На пользователя:
has_many :loans, :class_name => "Transaction", :foreign_key => "lender_id"
has_many :debts, :class_name => "Transaction", :foreign_key => "borrower_id"
Это дает вам:
u = User.first
u.loans # [transaction, transaction, ...]
u.debts # [transaction, transaction, ...]
И
t = Transaction.first
t.lender # User
t.borrower # User
Надеюсь, это поможет!