This stuff should probably be documented better, since it is not very
obvious.  Thanks for the help.  So, just to sum up, which associations
rely on other tables and which associations are responsible for
holding their own keys?

Thanks,

Carl

On Tue, 27 Jul 2004 21:34:44 +0900, David Heinemeier Hansson
<david / loudthinking.com> wrote:
> > I'm pretty confident that David would ensure ActiveRecord works just
> > fine with the above scenario.  What you have to type in, I'm not sure.
> > But something like this should do.
> >
> >   class Project < ActiveRecord::Base
> >     has_one :manager
> >   end
> >
> >   class Manager < ActiveRecord::Base
> >     has_many :project
> >   end
> 
> Actually, that's the primary difference between belongs_to and has_one.
> With belongs_to, you accept responsibility for the foreign key. With
> has_one, you expect the other side to hold it. So in your example, it
> would be:
> 
>    class Project < ActiveRecord::Base
>      belongs_to :manager
>    end
> 
>    class Manager < ActiveRecord::Base
>      has_many :projects
>    end
> 
> P.S.: Note that "has_many" expects the symbol as a plural if it is to
> do automated mapping.
> 
> 
> --
> 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
> 
>