STI with Polymorphism trouble

Hi,

I am having trouble using STI and polymorphism together. I tried "has_many :as" without success so I am trying to be more explicit. Here is what I have now

class Visual < ActiveRecord::Base   has_many :tags,            :foreign_key=>'resource_id',            :conditions=>['resource_type = ?', self.class.to_s],            :dependent=>:destroy end

class Picture < Visual end

Hi Josh,

Thanks for the reply.

The belongs_to side of things seems to work just fine unless i haven't worked into if far enough yet. It is the has_many side that causes me the grief.

I thought the following would work regardless of a STI or Polymophic existance.

has_many :tags,           :foreign_key=>'resource_id',           :conditions=>['resource_type = ?', self.class.to_s],           :dependent=>:destroy

I thought in the :conditions of the has_many there would be a way to use the attributes of the model that actually has_many. Is that possible?

Other things like

:conditions=>['blahblah = ?', self.id], :conditions=>['random_attribute = ?', self.foo],

Thanks again, Peter

Hi,

Can anyone confirm that what I thought would work below absoultely will not work? That is a has_many :conditions cannot depend on a particular instances attributes.

Thanks, Peter