# Polymorphic question

**URL:** <https://www.ruby-forum.com/t/polymorphic-question/162444>\
**Category:** Rails\
**Created:** [March 10, 2009, 1:41am UTC](https://www.ruby-forum.com/t/polymorphic-question/162444 "2009-03-10T01:41:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 10, 2009, 1:41am UTC](https://www.ruby-forum.com/t/polymorphic-question/162444/1 "2009-03-10T01:41:41Z")

</div>

I have a “ports” model I wanted to make polymorphic. I have an alarm  
table that has a port, and I also have a circuits model that has 2  
ports.

Is there a way to use the circuits model as polymorphic with 2 ports  
each one a different port?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 10, 2009, 10:37pm UTC](https://www.ruby-forum.com/t/polymorphic-question/162444/2 "2009-03-10T22:37:59Z")

</div>

anybody?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 11, 2009, 5:20am UTC](https://www.ruby-forum.com/t/polymorphic-question/162444/3 "2009-03-11T05:20:49Z")

</div>

Chris H. wrote:

> anybody?

It sounds like you will have to use an intermediate table that the  
circuits model will have a one-many relationship with and then use ports  
polymorphically in that intermediate table.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [March 12, 2009, 1:34am UTC](https://www.ruby-forum.com/t/polymorphic-question/162444/4 "2009-03-12T01:34:05Z")

</div>

Is there an easier way to implement this?  
Maybe other than polymorphic?

I have a circuits table that has 2 ports. What is the easiest way to do  
this?

On Tue, Mar 10, 2009 at 11:20 PM, Sj Tib
