나는 내 단위에 몇 가지 단위를 더하는 rspec 테스트를 작성했다.공장 아가씨 모임
두 개의 모델 => 루 브릭과 단위가 있습니다. 루 브릭에는 많은 유닛이 있습니다. 은 다음과 같습니다
@rubric.units.push Factory :text_unit
@rubric.save
가 그럼 난 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