Forum: Ruby on Rails Adding attributes to subclasses created using polymorphic associations

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C608d449f87ba87dd4a3f653afb304c1?d=identicon&s=25 Evan (Guest)
on 2008-10-19 03:27
(Received via mailing list)
Good evening.

I have a class, CustomerRequest, which I have subclassed into three
other classes, all different types of customer requests. I chose to
use polymorphic associations to map the subclasses in my database.

For one of the subclasses, InstallRequest, I have generated a new
model and defined a new table in the generated migration. However,
when I instantiate InstallRequest in the console the only attributes
that appear in the object are those of the superclass,
CustomerRequest. The columns I defined in the subclass' migration do
not appear as attributes of the object.

-I have verified that the subclass, InstallRequest, is defined as a
subclass of CustomerRequest, not ActiveRecord, in the model file.
-I have verified that the database has been migrated to the latest
revision.

Is this expected behavior or is there a bug in my code? I was
expecting the subclass to have all of the attributes of the superclass
as well as those defined in the migration file generated for the
subclass. If this is expected behavior how can I map the columns of
the subclass' table to the subclass objects?

Thanks.

Evan
This topic is locked and can not be replied to.