Optional model relations


#1

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?


#2

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

Meet up at RailsConf:
http://railsconf2007.conferencemeetup.com/