Относительно новый для рельсов и попытка моделировать очень простое семейное "дерево" с одной моделью Person, которая имеет имя, пол, father_id и mother_id (2 родителя). Ниже в основном то, что я хочу сделать, но, очевидно, я не могу повторить: children в has_many (первый будет перезаписан).
class Person < ActiveRecord::Base
belongs_to :father, :class_name => 'Person'
belongs_to :mother, :class_name => 'Person'
has_many :children, :class_name => 'Person', :foreign_key => 'mother_id'
has_many :children, :class_name => 'Person', :foreign_key => 'father_id'
end
Есть ли простой способ использовать has_many с 2 внешними ключами или, возможно, изменить внешний ключ на основе пола объекта? Или есть другой/лучший способ вообще?
Спасибо!