Is there a "maybe_belongs_to"?

Hi, I’m working on a project to register people for events, and was
looking for a little help on it.

I’ve got this class “Events”. Basically, there are going to be several
big events throughout time, and those events should not belong to
anybody/anything. But then, we’ve got sub events. For example, someone
could go to Event “HorseShow” and then go to Event “RidingClass”, part
of the horse show. What should I do to make that RidingClass belong to
another event, but not the HorseShow.

Also, Person is going to be attending HorseShow, and also RidingClass,
so I’ll have to deal with that… probably has many through. But
has_many :events, :through => :events probably doesn’t work.

Thanks in advance for your posts!


has_many :events, :through => :events probably doesn’t work

it does, if Events has events_id but needs another name:
has_many :events # for the normal relation
has_many :sub_events, :through => :events

if events_id is nil, it doesn’t belong to another event (like for

but i would keep it in the events model depending on, how deep your
events may be nested

you may have a look at this

works just the same, only they use parent_id
would look like this then:

in Events:
has_many :child_events, :foreign_id => :parent_id