I have a Code model factory like this:
Factory.define :code do |f| f.value \"code\" f.association :code_type f.association(:codeable, :factory =&
I'd suggest yet an other approach, which I think is clearer:
attr = attributes_for(:code).merge(code_type: create(:code_type))