# Using one model in multiple associations to another model

**URL:** <https://www.ruby-forum.com/t/using-one-model-in-multiple-associations-to-another-model/83894>\
**Category:** Rails\
**Created:** [January 30, 2007, 4:39pm UTC](https://www.ruby-forum.com/t/using-one-model-in-multiple-associations-to-another-model/83894 "2007-01-30T16:39:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [January 30, 2007, 4:39pm UTC](https://www.ruby-forum.com/t/using-one-model-in-multiple-associations-to-another-model/83894/1 "2007-01-30T16:39:14Z")

</div>

Looking for some guidance on how to accomplish the following…

Assume a ticket management system being developed, with a main Ticket  
model.

A Ticket has:  
a caller  
an assigned resource  
a closer  
a last-updater  
an escalation manager  
one or more copy-to’s

All of these are just different people from my users table.

Any one person in the user table could be any one of these on one or  
more tickets. That is, I could be the caller on one or more tickets, or  
the assigned resource or the copy-to.

The same person could be one or more of these on any one ticket. That  
is, I could be both the assigned resource and the closer on a particular  
ticket.

I’m not sure how to do this within Rails, without creating multiple  
tables and/or views. It’s not really polymorphic, as I understand it.  
It’s not really STI, as I that. It’s kind of a hybrid. Can it be done  
just by setting up the right associations with appropriate parms (like  
:source, :foreign\_key, :class\_name)?

Just need to be set in the right direction and given a good push…

Thanks.  
c.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [January 30, 2007, 4:54pm UTC](https://www.ruby-forum.com/t/using-one-model-in-multiple-associations-to-another-model/83894/2 "2007-01-30T16:54:38Z")

</div>

This thread will show you how to create multiple foreign keys in your  
model:

[http://www.ruby-forum.com/topic/95943](http://www.ruby-forum.com/topic/95943)

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [January 30, 2007, 5:26pm UTC](https://www.ruby-forum.com/t/using-one-model-in-multiple-associations-to-another-model/83894/3 "2007-01-30T17:26:15Z")

</div>

Mick S. wrote:

> This thread will show you how to create multiple foreign keys in your  
> model:
> 
> [How to Model a table with two foreign keys of the same table - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/95943)

Thanks a bunch.

And, um … wow, sorry - you’d think I would have seen that post this  
am.

cb.

---

<div class="post-metadata">

**Author:** ![yardboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9de0a6/32.png) [@yardboy](https://www.ruby-forum.com/u/yardboy)\
**Post date:** [January 30, 2007, 5:29pm UTC](https://www.ruby-forum.com/t/using-one-model-in-multiple-associations-to-another-model/83894/4 "2007-01-30T17:29:53Z")

</div>

da nada 😉

Mick
