私は、私のループルックにいくつかの単位を追加するrspecテストを書いています。ファクトリーガール協会
私は2つのモデル=> RubricとUnitsを持っています。 Rubricsには多くのユニットがあります。 それは次のようになります。
@rubric.units.push Factory :text_unit
@rubric.save
は、その後、私はfactory_girlを発見し、 工場として、このコードを書き換えることを試みました。しかし、それは動作していません。
この関連付けをFactory Girlに書き込むにはどうすればよいですか。
factory :common_rubric , :class => :common_info_rubric do |f|
f.sequence(:name) {|n| "common_info_rubric#{n}"}
end
factory :text_unit, :class => text_info_unit do |f|
f.association :common_rubric_with_unit
f.sequence(:name) {|n| "text_unit#n}" }
end
factory :common_rubric_with_unit , :parent => :common_rubric do |f|
f.units { |unit| unit.association(:text_info_unit) }
end
私は常にエラー
SystemStackError:
stack level too deep
質問全ての問題はモデル内のテーブルのundefault名前だった – nub
更新します。 そして読んだ後に http://robots.thoughtbot.com/post/254496652/aint-no-calla-back-girl 私は問題を解決します。それはここにhttp://pastie.org/2355251(なぜなら私は7時間前まで私の質問のために答えることができない) – nub