答案 0 :(得分:1)
文档:http://datamapper.org/docs/associations.html自定义关联部分。
class User
...
has n, :peeps, 'Peep',
:parent_key => [ :handle ], # local to this model (User)
:child_key => [ :user_handle ] # in the remote model (Peep)
end
class Peep
...
belongs_to :user, 'User',
:parent_key => [ :handle ], # in the remote model (Peep)
:child_key => [ :user_handle ] # local to this model (User)
end