# Make a STI-compatible finder for a polymorphic column?

**URL:** <https://www.ruby-forum.com/t/make-a-sti-compatible-finder-for-a-polymorphic-column/152394>\
**Category:** Rails\
**Created:** [November 3, 2008, 2:45pm UTC](https://www.ruby-forum.com/t/make-a-sti-compatible-finder-for-a-polymorphic-column/152394 "2008-11-03T14:45:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![budu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@budu](https://www.ruby-forum.com/u/budu)\
**Post date:** [November 3, 2008, 2:45pm UTC](https://www.ruby-forum.com/t/make-a-sti-compatible-finder-for-a-polymorphic-column/152394/1 "2008-11-03T14:45:29Z")

</div>

Hi,

I’ve got a model with a polymorphic column and STI models.  
I’ve added a finder to search for specific types.  
How can I search for a specific model that is STI because Rails stores  
the mother class name ?

class Activity \< ActiveRecord::Base  
belongs\_to :item, :polymorphic =\> true

named\_scope :filter\_items, lambda { |i| { :conditions =\> { :item\_type  
=\> i } } }  
end

class Person \< ActiveRecord::Base  
end

class Site \< ActiveRecord::Base  
end

class Event \< Site  
end

class Place \< Site  
end

Activity.filter\_items(‘Person’) works but Activity.filter\_items(‘Event’)  
and Activity.filter\_items(‘Place’) don’t work because Rails stores  
‘Site’ in item\_type column…

I would like to be able to search through STI and non-STI models…

Thanks for your answers,  
Nicolas.
