📅  最后修改于: 2022-03-11 15:04:48.384000             🧑  作者: Mango
class Task < ActiveRecord::Base
belongs_to :soldier
belongs_to :creator, class_name: Soldier, foreign_key: :created_by
end
class Soldier < ActiveRecord::Base
has_many :tasks
# Optional -- I'm unclear if you want this too?
has_many :created_tasks, class_name: Task, foreign_key: :created_by
end