# Adding attributes to subclasses created using polymorphic associations

**URL:** <https://www.ruby-forum.com/t/adding-attributes-to-subclasses-created-using-polymorphic-associations/151266>\
**Category:** Rails\
**Created:** [October 19, 2008, 3:27am UTC](https://www.ruby-forum.com/t/adding-attributes-to-subclasses-created-using-polymorphic-associations/151266 "2008-10-19T03:27:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![evan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/54ee81/32.png) [@evan](https://www.ruby-forum.com/u/evan)\
**Post date:** [October 19, 2008, 3:27am UTC](https://www.ruby-forum.com/t/adding-attributes-to-subclasses-created-using-polymorphic-associations/151266/1 "2008-10-19T03:27:02Z")

</div>

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
