0
我是使用DataMapper的新手,只想將一個類的屬性添加到另一個類的表中。我有兩個類,如下所示:我想添加'user'類中的'handle'屬性作爲'peep'表中的列。我已經要求所有相關的gem(不包括在下面),但我正在努力使用DataMapper語法。我嘗試了has n, :user
和belongs to
等的變體,但都導致'user_id has NULL values'
錯誤。DataMapper將另一個類的屬性添加到另一個類的表中。
類 '用戶':
class User
include DataMapper::Resource
property :id, Serial
property :email, String, format: :email_address, required: true, unique: true
property :handle, String, required: true
end
類 '窺視':
class Peep
include DataMapper::Resource
property :id, Serial
property :peep_content, String
property :created_at, DateTime
end