# .build for has\_one

**URL:** <https://www.ruby-forum.com/t/build-for-has-one/187764>\
**Category:** Rails\
**Created:** [April 28, 2010, 11:18pm UTC](https://www.ruby-forum.com/t/build-for-has-one/187764 "2010-04-28T23:18:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmcdougall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@lmcdougall](https://www.ruby-forum.com/u/lmcdougall)\
**Post date:** [April 28, 2010, 11:18pm UTC](https://www.ruby-forum.com/t/build-for-has-one/187764/1 "2010-04-28T23:18:27Z")

</div>

I am having problems understanding this concept.

I am guessing that, for has\_one/belongs\_to one should use something  
different from .build.

for example,  
if I have the following  
class Student \< ActiveRecord::Base  
has\_many :notes  
end

class Note \< ActiveRecord::Base  
belongs\_to :students  
end

Then

def new  
@student = Student.new  
@student.notes.build  
end

* * *

But when I have the following association :

class Student \< ActiveRecord::Base  
has\_one :econtact  
end

class Econtact \< ActiveRecord::Base  
belongs\_to :student  
end

then  
def new  
@student = Student.new  
@student.build\_econtact  
end

I am trying the latter, and it does not build the record with the  
association.

Can someone help, please  
Thanks  
-Luis

---

<div class="post-metadata">

**Author:** ![lmcdougall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@lmcdougall](https://www.ruby-forum.com/u/lmcdougall)\
**Post date:** [April 30, 2010, 7:32pm UTC](https://www.ruby-forum.com/t/build-for-has-one/187764/2 "2010-04-30T19:32:16Z")

</div>

Hi

You have to read

> **[Active Record Associations — Ruby on Rails Guides](https://guides.rubyonrails.org/association_basics.html)**
>
> Active Record AssociationsThis guide covers the association features of Active Record.After reading this guide, you will know: How to declare associations between Active Record models. How to understand the various types of Active Record...

especially sections 4.1.1.3 , 4.2.1.3 and 4.3.1.12

Sijo
