1
我在DataMapper中使用Padrino,我試圖做一個向模型添加關聯的遷移。例如,我開始使用此:DataMapper Association Migrations
class User
include DataMapper::Resource
property :id, Serial
property :name, String
end
class Post
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, Text
end
class Comment
include DataMapper::Resource
property :id, Serial
property :name, String
end
我用下面的結尾:
class User
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :posts
end
class Post
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, Text
belongs_to :user
has n, :comment
end
class Comment
include DataMapper::Resource
property :id, Serial
property :name, String
belongs_to :post
end
我已經有創建三個表遷移,但我對加入協會沒有。這些代碼將用於創建關聯的遷移?
謝謝,我想我必須先添加一個遷移。 – 2011-01-12 19:17:08