# Self-referential tags, has\_many\_polymorphs

**URL:** <https://www.ruby-forum.com/t/self-referential-tags-has-many-polymorphs/149653>\
**Category:** Rails\
**Created:** [September 27, 2008, 11:17am UTC](https://www.ruby-forum.com/t/self-referential-tags-has-many-polymorphs/149653 "2008-09-27T11:17:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [September 27, 2008, 11:17am UTC](https://www.ruby-forum.com/t/self-referential-tags-has-many-polymorphs/149653/1 "2008-09-27T11:17:39Z")

</div>

Hi,

I’m looking to add tagging to an application, and I would like to allow  
self-referential tags, so that I can tag my tags. With the goal of  
generating a flexible tag hierarchy.

After some googling it looks like acts\_as\_taggable is not the best piece  
of code, and I’m hoping to use the has\_many\_polymorphs plugin from  
[http://github.com/fauna/has\_many\_polymorphs/tree/master](http://github.com/fauna/has_many_polymorphs/tree/master). After  
installing this plugin, and generating a tagging framework using the  
builtin

script/generator tagging ModelA ModelB Tag --self-referential

command, I am unable to use the tags, and instead receive the following  
error

ActiveRecord::Associations::PolymorphicError: You can’t have a  
self-referential polymorphic has\_many :through without renaming the  
non-polymorphic foreign key in the join model.

Does anyone have an example of self-referential tagging working with  
this plugin, or can someone recommend a better way to achieve taggable  
tags?

Thanks – Eric
