0
我试图确定一个特定组织有多少会议时间,但这并不像看起来那么容易,因为某些关系很复杂。Rails:与3个键的复杂HABTM关系?
class Meeting < ActiveRecord::Base
has_and_belongs_to_many :people
end
class Person < ActiveRecord::Base
has_any_belongs_to_many :meetings
has_and_belongs_to_many :positions
end
class Position < ActiveRecord::Base
has_and_belongs_to_many :people # b/c over time more than one person
may hold this position over time
belongs_to :organization
end
class Organization < ActiveRecord::Base
has_many :positions
end
,因为人们可能会随着时间改变位置(和组织),当有人到会,我也需要记在那个时候他们的立场,以便理货是准确的。因为HATBM连接表隐式处理(meetings_people),所以我无法跟踪位置。我如何在这种组合中添加位置,以及编写查询以获得每个组织的总会议时间的最佳方式是什么?
在此先感谢您提供的任何帮助或建议!