# Question regarding has\_one and association\_build

**URL:** <https://www.ruby-forum.com/t/question-regarding-has-one-and-association-build/167233>\
**Category:** Rails\
**Created:** [May 5, 2009, 6:48pm UTC](https://www.ruby-forum.com/t/question-regarding-has-one-and-association-build/167233 "2009-05-05T18:48:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e4f/32.png) [@eric99](https://www.ruby-forum.com/u/eric99)\
**Post date:** [May 5, 2009, 6:48pm UTC](https://www.ruby-forum.com/t/question-regarding-has-one-and-association-build/167233/1 "2009-05-05T18:48:30Z")

</div>

In the doc, there’s is a note saying association\_build “only works if  
an association already exists. It will NOT work if the association is  
nil.” But in my test, it works fine when the association is nil. For  
example,

class Post \< ActiveRecord::Base  
has\_one :author

def after\_initialize  
build\_author  
end  
end

This works perfectly for me. So is the warning in the doc something I  
should be worried about?

Link to doc:

> **[ActiveRecord::Associations::ClassMethods](https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M001790)**
>
> Associations are a set of macro-like class methods for tying objects together through foreign keys.

Thanks,  
Eric
