I have a Code model factory like this:
Factory.define :code do |f|
f.value \"code\"
f.association :code_type
f.association(:codeable, :factory =&
Here's another way. You probably want to omit the id
, created_at
and updated_at
attributes.
FactoryGirl.build(:car).attributes.except('id', 'created_at', 'updated_at').symbolize_keys
Limitations:
create
, as in association :user, strategy: :create
. This strategy can make your factory very slow if you don't use it wisely.