Acts_as_taggable and single table inheritance


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

class A < AR:Base

class B < A

class C < A

(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?



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



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

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.



Please try this patch: