polymorphic has_many from ActiveRecord::Base????

I have a polymorphic thingy called fields and I need to on each and every model, so I'd like to do the has_many from the base class, like this...

ActiveRecord::Base.class_eval do   has_many :fields, :as => :model, :dependent => true end

It fails with this no method error (class_of_active_record_descendant)

/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/ base.rb:1369:in `class_of_active_record_descendant':NoMethodError: undefined method `abstract_class?' for Object:Class

Is there a better way to do this???

Instead of doing a class_eval, have you tried this:

ActiveRecord::Base   has_many :fields, :as => :model, :dependent => true end

If you put this in a some_name.rb file in your models, the AR::Base class will be extended with the functionality, which will then be inherited by your models. It might work...

Brent