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
on 2005-11-19 19:39
on 2005-11-19 19:43
Sorry i meant "has_one" not "has_a".
on 2005-11-19 19:57
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 2005-12-07 00:55
Awesome I was trying to figure this exact same thing out and this worked perfectly, thanks.