Evan
2008-Oct-19 01:26 UTC
Adding attributes to subclasses created using polymorphic associations
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---