# Optional has\_one association

**URL:** <https://www.ruby-forum.com/t/optional-has-one-association/55746>\
**Category:** Rails\
**Created:** [March 23, 2006, 3:59pm UTC](https://www.ruby-forum.com/t/optional-has-one-association/55746 "2006-03-23T15:59:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [March 23, 2006, 3:59pm UTC](https://www.ruby-forum.com/t/optional-has-one-association/55746/1 "2006-03-23T15:59:10Z")

</div>

Hi!

I have a has\_one association which is used for extending an entity,  
like:

class User \< ActiveRecord::Base  
has\_one :user\_ex

#name, email  
end

class UserEx \< …  
#country, city, street…  
end

The UserEx entity is optional (there are users without extended info).  
My problem is: if u is a User object which has no user\_ex extension,  
activerecord always tries to fetch the UserEx object whenever I  
write u.user\_ex (it thinks user\_ex isn’t yet loaded). I also want to  
include the user\_ex association when I load some users. What is  
the simplest way to do this?

Thanks,  
Adam
