# Polymorphic question w/r/t acts\_as\_taggable plugin use

**URL:** <https://www.ruby-forum.com/t/polymorphic-question-w-r-t-acts-as-taggable-plugin-use/134452>\
**Category:** Rails\
**Created:** [April 10, 2008, 11:54pm UTC](https://www.ruby-forum.com/t/polymorphic-question-w-r-t-acts-as-taggable-plugin-use/134452 "2008-04-10T23:54:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [April 10, 2008, 11:54pm UTC](https://www.ruby-forum.com/t/polymorphic-question-w-r-t-acts-as-taggable-plugin-use/134452/1 "2008-04-10T23:54:23Z")

</div>

I’ve been using the acts\_as\_taggable\_on\_steroids plugin successfully  
for awhile with models descended directly from ActiveRecord, but just  
ran into something strange in a new use case where I have models that  
are subclasses of other models.

I’m looking for an explanation and a workaround or correction to the  
way I’m doing things and it occurs to me that someone may have an  
answer if they have good knowledge about rails’ polymorphic operation  
OR about the way acts\_as\_taggable works…

Here’s my problem -

1. Models -

class Group \< ActiveRecord::Base

class Circle \< Group

class SupportCircle \< Circle

1. I have Circle declared as acts\_as\_taggable

2. when I tag a Circle, the ‘taggings’ table record for it has ‘Group’  
for the ‘taggable\_type’ column

Q1: why isn’t it ‘Circle’ for the ‘taggable\_type’?  
Q2: where in the code is this assignment of the value done? (I can’t  
seem to find it and assume it’s some “under the covers” magic that  
Rails is doing…?)

1. acts\_as\_taggable.rb’s ‘find\_tagged\_with’ method does the query  
with a join that has this fragment:

AND #{table\_name}\_taggings.taggable\_type = ‘#{name}’

So, when I do a search for Circle objs tagged with a tag, it fails to  
find those tagged objs because when I call  
Circle.find\_tagged\_with(tag), the ‘name’ is coming in as ‘Circle’  
while the entry in the table is ‘Group’ as described above.

Q3: why is the search value inconsistent with the ‘tagging’ insert’s  
assignment of value for ‘taggable\_type’?

1. I want to start tagging SupportCircle’s and not sure of a few  
things…

Q4: with an acts\_as\_ declaration, do I need to explicitly declare that  
in a subclass or will SupportCircle be taggable because Circle is  
declared so?  
Q5: if I want to distinguish between Circles and SupportCircles in my  
searches, I do separate calls for each with  
Circle.find\_tagged\_with(tag) and SupportCircle.find\_tagged\_with(tag)  
respectively, and from the look of that query, I’ll _only_ get Circles  
from the first and SupportCircles from the second, right? (yes, I  
think… just checking 'cause of the unexpected behaviors I’m seeing)

* * *

Sorry for the length of this and all the questions, but as I said  
above, perhaps some of you will know specifics of acts\_as\_taggable and  
others may now the general Rails answers and that will help me figure  
out how to make what I want to do work.

Thanks in advance.
