chris
1
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
chris
2
Sorry i meant “has_one” not “has_a”.
chris
3
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
chris
4
Awesome I was trying to figure this exact same thing out and this worked
perfectly, thanks.