数据映射器协会 - 什么代码?
Data Mapper Associations - what code?
我查看了 DataMapper 文档,但正在努力了解如何执行此操作。我有两个 table,我只是想添加来自用户 table 的 'handle' 属性作为 Peeps table 的一列 - 如下所示?
文档: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
我查看了 DataMapper 文档,但正在努力了解如何执行此操作。我有两个 table,我只是想添加来自用户 table 的 'handle' 属性作为 Peeps table 的一列 - 如下所示?
文档: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