People, If I have a table "books" and a table "comments" and if there is either ZERO or ONE comment per book then: - "Comment" belongs_to "Book" but what is the relationship of "Book" to "Comment"? Thanks, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney NSW 2001 Australia Mobile: +61:(0)411-185-652 Fax: +61:(0)2-8221-9599 E-mail: phil@pricom.com.au
2006/8/19, Philip Rhoades <phil@pricom.com.au>:> > People, > > If I have a table "books" and a table "comments" and if there is either > ZERO or ONE comment per book then: > > - "Comment" belongs_to "Book" > > but what is the relationship of "Book" to "Comment"?"book" has_many :comments -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060819/a2fd6bc8/attachment.html
Rodrigo, On Sat, 2006-08-19 at 12:05 -0400, Rodrigo Fuentealba wrote:> > > 2006/8/19, Philip Rhoades <phil@pricom.com.au>: > People, > > If I have a table "books" and a table "comments" and if there > is either > ZERO or ONE comment per book then: > > - "Comment" belongs_to "Book" > > but what is the relationship of "Book" to "Comment"? > > "book" has_many :commentsSo "has_one" means EXACTLY one and "has_many" could be zero OR more? Thanks, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney NSW 2001 Australia Mobile: +61:(0)411-185-652 Fax: +61:(0)2-8221-9599 E-mail: phil@pricom.com.au