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
You can use the association
method both ways:
Factory.define :foo do |f|
# ...
f.association :bar
end
If that won't work, you can associate them manually using a callback. Here's an example from one of my apps:
Factory.define :live_raid do |raid|
end
Factory.define :live_raid_with_attendee, :parent => :live_raid do |raid|
raid.after_create { |r| Factory(:live_attendee, :live_raid => r) }
end