# Acts\_as\_taggable and single table inheritance

**URL:** <https://www.ruby-forum.com/t/acts-as-taggable-and-single-table-inheritance/61204>\
**Category:** Rails\
**Created:** [May 21, 2006, 5:28pm UTC](https://www.ruby-forum.com/t/acts-as-taggable-and-single-table-inheritance/61204 "2006-05-21T17:28:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![olbrich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/5f9b8f/32.png) [@olbrich](https://www.ruby-forum.com/u/olbrich)\
**Post date:** [May 21, 2006, 5:28pm UTC](https://www.ruby-forum.com/t/acts-as-taggable-and-single-table-inheritance/61204/1 "2006-05-21T17:28:18Z")

</div>

I’ve set up a couple of STI models like such that we get something like  
this…

class A \< AR:Base

class B \< A  
acts\_as\_taggable

class C \< A  
acst\_as\_taggable

(using the acts\_as\_taggable plugin)

I can tag things just fine this way, the problem I encounter is that the  
taggings are listed with the base class (“A”) and not the appropriate  
subclass (“B” or “C”). This is problematic because I need to be able to  
generate a tag cloud by the appropriate ‘class’, and I don’t want tags  
from “B” mixing with those from “C”.

Has anyone else encountered this problem before?

\_Kevin

---

<div class="post-metadata">

**Author:** ![olbrich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/5f9b8f/32.png) [@olbrich](https://www.ruby-forum.com/u/olbrich)\
**Post date:** [May 30, 2006, 7:18am UTC](https://www.ruby-forum.com/t/acts-as-taggable-and-single-table-inheritance/61204/2 "2006-05-30T07:18:24Z")

</div>

On Sun, May 21, 2006 at 03:27:22PM -0000, Kevin O. wrote:

> acst\_as\_taggable
> 
> \_Kevin

This might be related to the problem I’m running into as well, and was  
about to ask the list.

Model is similar to above:

class A \< AR:Base  
acts\_as\_tagable

class B \< A

class C \< A

B.find\_all acts as it should—only getting objects that belong to the  
“B” class.

However, B.find\_tagged\_with(‘blah’) returns all of the “A” class objects  
tagged with ‘blah’, instead of only the “B” class objects.

Is there a work-around for this? Should a bug be filed somewhere?

I hate to add a conditional for Type = ‘B’ when working with the ‘B’  
class should constrain the results to the “B” objects.

Thanks,  
Wyatt

---

<div class="post-metadata">

**Author:** ![olbrich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/5f9b8f/32.png) [@olbrich](https://www.ruby-forum.com/u/olbrich)\
**Post date:** [May 30, 2006, 12:25pm UTC](https://www.ruby-forum.com/t/acts-as-taggable-and-single-table-inheritance/61204/3 "2006-05-30T12:25:33Z")

</div>

Please try this patch:

[http://dev.rubyonrails.org/ticket/3928](http://dev.rubyonrails.org/ticket/3928)

-Sean
