# Optional model relations

**URL:** <https://www.ruby-forum.com/t/optional-model-relations/91382>\
**Category:** Rails\
**Created:** [April 8, 2007, 1:28am UTC](https://www.ruby-forum.com/t/optional-model-relations/91382 "2007-04-08T01:28:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![azazel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@azazel](https://www.ruby-forum.com/u/azazel)\
**Post date:** [April 8, 2007, 1:28am UTC](https://www.ruby-forum.com/t/optional-model-relations/91382/1 "2007-04-08T01:28:30Z")

</div>

I’m currently working on an application and have a bit of a problem with  
relations.

The models Im working on right now are: User and Document

User has many documents  
Documents always belong to one user

The thing is, there’s a point where the user may have no documents at  
all, because he hasn’t created one yet.

Is ‘has many’ adequate for this relationship?

---

<div class="post-metadata">

**Author:** ![azazel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@azazel](https://www.ruby-forum.com/u/azazel)\
**Post date:** [April 8, 2007, 2:27am UTC](https://www.ruby-forum.com/t/optional-model-relations/91382/2 "2007-04-08T02:27:43Z")

</div>

On Apr 7, 2007, at 4:28 PM, azazel wrote:

> The thing is, there’s a point where the user may have no documents at  
> all, because he hasn’t created one yet.
> 
> Is ‘has many’ adequate for this relationship?

Yup

–  
Building an e-commerce site with Rails?  
[http://agilewebdevelopment.com/rails-ecommerce](http://agilewebdevelopment.com/rails-ecommerce)

Meet up at RailsConf:  
[http://railsconf2007.conferencemeetup.com/](http://railsconf2007.conferencemeetup.com/)
