acts_as_taggable with single-table inheritance?

Martin Longo wrote:

Does anyone have any experience making this work? I installed the
plugin and tried the following:

class SomeClass < ActiveRecord::Base

class SubClass1 < SomeClass

class SubClass2 < SomeClass


and notice that taggable_type = SomeClass

when I do SubClass2.find_tagged_with("tag") a SubClass1 object is

Any help would be greatly appreciated!


Posted via

Yeah, it has issues. The STI mechanism will force the 'class' column
to be 'SomeClass' even if it is actually a subclass of that.

I had to do some nasty hackery to get around that. It involved adding
another column that stored the classname of the object. It's messy,
and untested, so I would be hesitant about sharing it.

You can get around this by doing this...

SubClass.find_tagged_with("tag").delete_if {|x| !x.kind_of? SubClass1 }