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.