# Factory\_girl factory gem: problem with simple associations

**URL:** <https://www.ruby-forum.com/t/factory-girl-factory-gem-problem-with-simple-associations/185543>\
**Category:** Rails\
**Created:** [March 22, 2010, 3:02pm UTC](https://www.ruby-forum.com/t/factory-girl-factory-gem-problem-with-simple-associations/185543 "2010-03-22T15:02:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/91b2a8/32.png) [@Grary](https://www.ruby-forum.com/u/Grary)\
**Post date:** [March 22, 2010, 3:02pm UTC](https://www.ruby-forum.com/t/factory-girl-factory-gem-problem-with-simple-associations/185543/1 "2010-03-22T15:02:04Z")

</div>

Hi,

Can anyone familiar with the use of factory\_girl please comment on why  
I don’t succeed with the following:

has\_one\_instance = Factory.build(:has\_one\_class)  
assert\_equal 10, has\_one\_instance.belongs\_to\_class.some\_attribute

…when I’ve constructed the relevant factories, as follows:

Factory.define :belongs\_to\_class do |f|  
f.some\_attribute 10  
…  
f.association :has\_one\_class, :factory =\> :has\_one\_class  
end

Factory.define :has\_one\_class do |f|  
…  
end

…and the model classes have the indicated belongs\_to:has\_one  
relationship?

(A further complicating factor may be the peculiar warning message I’m  
getting post-factory\_girl install: Warning:  
Gem::Dependency#version\_requirements is deprecated and will be removed  
on or after August 2010. Use #requirement)

Thanks for any comment,

Grar

---

<div class="post-metadata">

**Author:** ![Grary](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/91b2a8/32.png) [@Grary](https://www.ruby-forum.com/u/Grary)\
**Post date:** [March 22, 2010, 6:01pm UTC](https://www.ruby-forum.com/t/factory-girl-factory-gem-problem-with-simple-associations/185543/2 "2010-03-22T18:01:12Z")

</div>

No takers, huh?
