Hi,
I just got into polymorphic relations. It works very nice, but I ran
into a strange problem that can be reproduced easily. I don’t have
another workaround than to uncomment an include, but thats lame. Here it
is:
My models
a generic comment class (it has a name and message)
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
another model that has comments
class Batch < ActiveRecord::Base
has_many :comments, :as => :commentable
end
Now start a rails console and be amazed by the following:
C:\rails\atlas>ruby script\console
Loading development environment (Rails 2.0.1)
include REXML
=> ObjectBatch.find(:first).comments
NoMethodError: undefined method `table_name’ for REXML::Comment:Class
(more error lines follow here)
It looks like REXML gets in the way of my real comments here. What can I
do to prevent this?
regards, Johan van der Kuijl