I am still trying to wrap my head around FG… can someone explain me
why I
am seemingly having to reload an object to have access to the correct
association value which I updated since creating the object with FG.
Here is
an example (Factory below also):
@person = Factory(:person)
@person.addresses.size.should == 0
address = Factory(:address)
@person.add_address(address)
@person = Person.find(@person.id) # if I dont do this I get the old
value,
0, but if I reload I get the right value, 1.
@person.addresses.size.should == 1
@person.addresses[0].person_id.should == @person.id
Factory.define :person do |f|
f.first_name {“MyString”}
f.middle_name {“MyString”}
f.last_name {“MyString”}
end
Factory.define :address do |f|
f.person_id {1}
f.address {“MyString”}
f.zip {“94587”}
f.city {“MyString”}
f.state {“MyString”}
end