Populating an association with children in factory_girl

前端 未结 5 1963
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 17:16

I have a model Foo that has_many \'Bar\'. I have a factory_girl factory for each of these objects. The factory for Bar has an association to Foo; it will instan

5条回答
  •  旧巷少年郎
    2020-12-12 17:43

    FactoryGirl now has a :method => :build option you can use on the association, which will build the associated object rather than creating it.

    #64: Building an object creates associations

提交回复
热议问题