# Q: belongs\_to & build

**URL:** <https://www.ruby-forum.com/t/q-belongs-to-build/188861>\
**Category:** Rails\
**Created:** [May 19, 2010, 3:12pm UTC](https://www.ruby-forum.com/t/q-belongs-to-build/188861 "2010-05-19T15:12:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [May 19, 2010, 3:12pm UTC](https://www.ruby-forum.com/t/q-belongs-to-build/188861/1 "2010-05-19T15:12:04Z")

</div>

hi

invite \<belongs\_to\> location  
location \<has\_one\> invite

background: location is not set at the time of the invite…

i = invite.find(1)

> > how do i build the location and update the invite (location\_id) in  
> > one go? (build doesnt set the foreign key for me…)

loc = i.build\_location(:title=\>‘test’)  
loc.save!

> > create a location, but fk is missing…

thx
