# Polymorphic :through associations

**URL:** <https://www.ruby-forum.com/t/polymorphic-through-associations/140433>\
**Category:** Rails\
**Created:** [June 13, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/polymorphic-through-associations/140433 "2008-06-13T22:15:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![twoism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e57/32.png) [@twoism](https://www.ruby-forum.com/u/twoism)\
**Post date:** [June 13, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/polymorphic-through-associations/140433/1 "2008-06-13T22:15:40Z")

</div>

Could someone please help me with this association scheme? I am  
familiar with habtm as well as the :through association but this one  
has me stumped.

Here is an example DB.

## Tags Table:

id  
name

## Taggables Table:

id  
tag\_id  
taggble\_type  
taggable\_id

For purposes of this example say that there are 2 other tables that  
can be tagged and their model name would appear in the taggable\_type  
field along with their id in the taggable id.

I have seen this done somewhat with the:

belongs\_to :taggable, :polymorphic =\> true

but never with a join table or a :through to store extra info.  
Can this be done this way or am I completely off track?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![twoism](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e57/32.png) [@twoism](https://www.ruby-forum.com/u/twoism)\
**Post date:** [June 21, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/polymorphic-through-associations/140433/2 "2008-06-21T23:03:22Z")

</div>

Maybe something like this would work for you?

[http://wiki.rubyonrails.org/rails/pages/ManytoManyPolymorphicAssociations](http://wiki.rubyonrails.org/rails/pages/ManytoManyPolymorphicAssociations)

-ns
