On 1/18/06, Philip R. email@example.com wrote:
In the cookbook eg, categories has_many recipes but in a book eg, book
has_one description - doesn’t that mean that the id of the description
should be the same as the id of the book (instead of having it’s own
“description_id” in the book table?
The category -> recipes tables look like this:
The book -> description relationship implies this kind of setup:
has_one :description #Note the singular, rather than plural.
@book = Book.find(:first)
@book.description returns the instance of Description that was
associated with that book.
In a typical setup, every ActiveRecord class (Book, Description, etc)
maps to a database table, and that table has an ‘id’ column for the
primary key. Descriptions each have a unique id independent of their