On Mon, May 10, 2010 at 8:52 AM, Dieter Lunn <coder2...@gmail.com> wrote:
> I would do:
>
> Passengers belong_to Car
> Car has_many Passengers
> Car has_one Driver, :class => Passenger
>

I'd do something similar.

Actually if I had the freedom, I'd probably rename the class Passenger
to something like Person since Driver and Passenger are really roles,
not entities.

class Person < ActiveRecord::Base
   belongs_to :car
end

class Car < ActiveRecord::Base
   belongs_to :driver, :class => ;person
   has_many :passengers, :class => person
end


-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to