我有一个问题,我似乎无法包裹我的头。Rails邀请参加活动
我有一个邀请,模型,将代表的姓名,地址,的人的邀请,加1或者不号码等
我也有有名称,地点的事件模型,和时间事件。
我想通过像Schedule这样的东西来将Invites to Events关联起来。我希望能够创建预定义的计划作为事件的集合,然后将邀请与特定的计划相关联。
到目前为止,我有以下几点。
class Invite < ActiveRecord::Base
belongs_to :schedule
has_many :events, :through => :schedules
#a schedule_id column exists in the invites table
end
class Event < ActiveRecord::Base
has_many :schedules
has_many :invites, :through => :schedules
end
class Schedule < ActiveRecord::Base
has_many :events
has_many :invites
end
如果我们有活动e1, e2, e3
并邀请i1, i2
和时间表s1 has e1 and e2' and 's2 has e2 and e3
然后我希望能够邀请相关联与i1
附表s1
和附表s2
邀请i2
。
我可以得到Invites到Schedules的关系,但是与Invites一起的多对多Events-to-Schedules目前令我困惑。有什么想法吗?任何其他方式来思考这个?
我最终希望能够说invite.events
和event.invites
。
我说得对吗;你有邀请有多对多的事件和时间表是关联表?包含关于事件周围的关联的元数据的时间表等。 – 2009-12-09 04:41:02
是的......听起来正确。 – thomas 2009-12-09 12:32:14