STI and polymorphism confusion

Dave Myron wrote:

Guys I must not be getting enough sleep, cause I'm really feeling lost
about this one. I've read lots about STI and polymorphism gleefully
playing in the meadow together. But apparently my models are the giant
sinkhole the wonderful kids fell into. (Do I sound tired?) Anyway:

To me, this seems pretty standard...

class Content < AR::Base
  acts_as_taggable # plugin

class Photo < Content; end

class Album < Content; end

Normal STI table for contents. I have taggings and tags for

My issue is after doing this:
Photo.find(:first).tag_with 'test'
Album.find(:first).tag_with 'test'
There are now two records in taggings with the IDs of the taggable and
taggable_type = 'Content' (wish this could be 'Album' and 'Photo' but I
understand that this must be the base_class). Now, I want to get all the
photos that are tagged with 'test'. I'm using the provided methods with

Photo.find_tagged_with 'test'

The problem is that this returns both records because find_tagged_with
searches for taggable_type = 'Content'! Am I doing something wrong here?

Thanks for taking the time to read this,

Posted via

Nope, that's a limitation of STI (I forget why). I worked around it by
adding another column and monkeypatching the acts_as_taggable to
populate that column with the actual class name.