> I'm still new to ActiveRecord, so forgive me if this is obvious, but
> is it necessary in a relationship like the one below for each table to
> refer to the other?  In this relationship, it would be sufficient for
> the projects table to have a manager_id and it would not be necessary
> for the managers table to have a project_id, or vice versa.  Does
> ActiveRecord require both tables to refer to one another?

Ahhh, no, no. In the example, the only *table* that holds any 
information about the relationship is "managers", which has a 
project_id foreign_key. Both *classes* know about the relationship, 
though. But that's just to get the association methods on both and to 
communicate the design through code.

In Active Record, it's the default style that the "belonging" table is 
the one that holds the foreign key. So has_many and has_one depends on 
the other guy to hold a foreign key for them.


>> * Added natural object-style assignment for has_one and belongs_to
>>    associations. Consider the following model:
>>
>>      class Project < ActiveRecord::Base
>>        has_one :manager
>>      end
>>
>>      class Manager < ActiveRecord::Base
>>        belongs_to :project
>>      end
>>
>>    Earlier, assignments would work like following regardless of which
>> way the
>>    assignment told the best story:
>>
>>      active_record.manager_id = david.id
>>
>>    Now you can do it either from the belonging side:
>>
>>      david.project = active_record
>>
>>    ...or from the having side:
>>
>>      active_record.manager = david
>>
>>    If the assignment happens from the having side, the assigned 
>> object is
>>    automatically saved. So in the example above, the project_id
>> attribute on
>>    david would be set to the id of active_record, then david would be
>> saved.
>
>
> !DSPAM:410637d7638491553813545!
>
--
David Heinemeier Hansson,
http://www.rubyonrails.org/  -- Web-application framework for Ruby
http://www.instiki.org/      -- A No-Step-Three Wiki in Ruby
http://www.basecamphq.com/   -- Web-based Project Management
http://www.loudthinking.com/ -- Broadcasting Brain
http://www.nextangle.com/    -- Development & Consulting Services