I have an audit table with fields auditor_id and manager_id that both link to the people table: AUDIT: id name datecreated auditor_id manager_id PEOPLE: id name I have no idea how to link both fields from audit to people?? any ideas?? I''m pulling my hair out trying to figure this out, please help!! I know that if it were just one field then i''d call the field person_id. Thanks, Chris -- Posted via http://www.ruby-forum.com/.
Sorry i meant "has_one" not "has_a". -- Posted via http://www.ruby-forum.com/.
Benjamin Curtis
2005-Nov-19 18:54 UTC
Re: How to get two "has_a" relationships to the same table?
You probably want something like this: class Audit < ActiveRecord::Base belongs_to :auditor, :class_name => ''Person'', :foreign_key => ''auditor_id'' belongs_to :manager, :class_name => ''Person'', :foreign_key => ''manager_id'' end On Nov 19, 2005, at 10:39 AM, Chris wrote:> I have an audit table with fields auditor_id and manager_id that both > link to the people table: > > AUDIT: > id > name > datecreated > auditor_id > manager_id > > PEOPLE: > id > name > > I have no idea how to link both fields from audit to people?? any > ideas?? > I''m pulling my hair out trying to figure this out, please help!! > > I know that if it were just one field then i''d call the field > person_id. > > Thanks, > Chris > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails