FactoryGirl: attributes_for not giving me associated attributes

前端 未结 7 654
再見小時候
再見小時候 2020-12-08 14:08

I have a Code model factory like this:

Factory.define :code do |f|
    f.value \"code\"
    f.association :code_type
    f.association(:codeable, :factory =&         


        
7条回答
  •  无人及你
    2020-12-08 14:29

    I'd suggest yet an other approach, which I think is clearer:

    attr = attributes_for(:code).merge(code_type: create(:code_type))
    

提交回复
热议问题