Skip to content

Instantly share code, notes, and snippets.

@pathsny
Created April 27, 2010 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pathsny/380916 to your computer and use it in GitHub Desktop.
Save pathsny/380916 to your computer and use it in GitHub Desktop.
class Payment
include DataMapper::Resource
belongs_to :payee, User
belongs_to :payer, User
property :id, Serial
# ...
end
class User
include DataMapper::Resource
has n, :payments_as_payer, Payment, :child_key => [:payer_id]
has n, :payments_as_payee, Payment, :child_key => [:payee_id]
has n, :payees, User, :through => :payments_as_payer # need help here
has n, :payers, User, :through => :payments_as_payee # need help here
property :id, Serial
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment