Christopher Rericha
2007-Jan-28 21:40 UTC
Avoiding duplication in Has Many :through polymorphic associations
Hi everyone, I have a group of classes that I associate to a Note class through a has_many :through polymorphic association, which works great! However, I''ve noticed that I have a good amount of duplicate functionality within these classes for the Note interface. I would like to move this functionality as well as the actual has_many :through and join table associations into one common file in order to adhere to the DRY principle. I tried to make my classes inherit from a NoteInterface class that contained the associations, but the association would use the parent class (NoteInterface) as the type in the join table. I already had to use set_table() to get AR to use the name of the child class for the table. Is there a similar way to override the name of the type a polymorphic association will use? I also tried putting the associations in a module and use it as a mixin, but when ruby parses the file, it doesn''t know what to do with them. Has anyone else tried to do this? Is this even be possible? Thanks! Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---