0
我試圖用Fabrication寶石,以便在軌項目開發來填充分貝。製作寶石困難協會
的問題是我覺得製作是非常強大的工具,但是很簡單的關聯,我不能做任何事情。
例如,我有以下型號
class User < ActiveRecord::Base
has_many :order, :dependent => :destroy
has_many :src_reviews, :class_name => 'Review', :foreign_key => '...'
has_many :dst_reviews, :class_name => 'Review', :foreign_key => '...'
class Review < ActiveRecord::Base
belongs_to :src_user, :class_name => 'User', :foreign_key => '...'
belongs_to :dst_user, :class_name => 'User', :foreign_key => '...'
end
class Order < ActiveRecord::Base
belongs_to :user
不讓考慮不同scenarious。
我不知道如何從爲了落實用戶
Fabricator(:order) do
...
user { Fabricate(:user) }
end
Fabricator(:user) do
...
end
Q簡單關聯:但是我不知道我是否能在另一側做。
Fabricator(:order) do
...
end
Fabricator(:user) do
orders {#somehow create 5 orders for each user}
end
而最困難的法寶是如何製造審查與src_user和dst_user這樣莫名其妙地混合起來,最好有用戶,讓很多的評論,並同用戶接收很多評論。
謝謝你的幫助。