# HABTM question or :through association

**URL:** <https://www.ruby-forum.com/t/habtm-question-or-through-association/129141>\
**Category:** Rails\
**Created:** [February 14, 2008, 8:06pm UTC](https://www.ruby-forum.com/t/habtm-question-or-through-association/129141 "2008-02-14T20:06:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [February 14, 2008, 8:06pm UTC](https://www.ruby-forum.com/t/habtm-question-or-through-association/129141/1 "2008-02-14T20:06:23Z")

</div>

Okay, we’ll I’ve been working on this crazy fun project (lol, maybe  
fun when we’re done). We’re working on a registration system for  
conventions [and sadly, not even getting paid ☹], so I want to  
ensure that we start off correctly before getting to far into  
something broken.

We’ve got Models that are Attendees, Events, and Payments. That’s the  
only simple part. After that, we have Attendees which are going to  
Events, and events that belong to bigger events! Some events have  
payments, some do not.

So - I was thinking is the best way to do this be a HABTM type of  
thing. The inner table would reference something like “Attendences”  
and have Attendee\_id and Event\_id.

Or would it be better to do something polymorphic. Have events be  
attendable and payable. But then, I don’t think you have an Attendee  
go to more than one event, right? Because I can’t picture how the  
database would have that setup.

Or is there a more creative way that would mean to create a Model  
called “Attendences” to tie Events, Attendees, and Payments  
together… or would that not be necessary, because that’s probably  
what HABTM.

Imagine we have a Person like this:

Person (“John”)  
—\> Event (“Anime Convention”)  
----------\> Payment (“John’s con payment”)  
----------\> Event (“Art Show”)  
-----------------\> Payments (“John’s art show payment”)

Any suggestions on the best way to implement this. Or maybe does  
anyone have a plugin or example? Any help would be greatly  
appreciated… we want to make some noise with this program, 🙂

-Ryan

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [February 14, 2008, 8:23pm UTC](https://www.ruby-forum.com/t/habtm-question-or-through-association/129141/2 "2008-02-14T20:23:29Z")

</div>

Well, I guess I’ll share that I think :through associations will  
probably be my need, anybody concur or dissent?

Person  
id  
name  
info

Event  
id  
name  
info

Attendences  
id  
person\_id  
event\_id  
payment\_id

Will it cause any trouble not calling it Event\_person?
