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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---