Sateesh Kambhamapati wrote: > I have doubts on Polymorphic Assosiations. > On Which situations we are using these?? > What are the advantages?
I use polymorphic associations all over the place in one application... mostly for the reporting and research aspect of the application. A 'functional_area' model can be related to a project, a testing scenario, a specific unit test, a functional requirement, or a marketing requirement. With polymorphic links, I have 1 arealink table that can link a functional area to any of those other models. The same logic applies to 'modules', 'applications', 'features', 'functional_requirements', etc. The initial ERD I received was almost unreadable and looked like a badly done Spirograph drawing (does anyone else know what those are anymore?) When I switched to polymorphic associations, I eliminated 18 separate join tables from the design in favor of several polymorphic join tables and was able to create 1 'linking' partial (about 30 lines of haml) to manage creating/removing links no matter which polymorphic association was being altered from a source model to any type of target model. When I have the time, I'm going to look into a double-polymorphic join table and get those join tables down to 1. The only downside I've seen thus far is that I have to restart my server when I add polymorphic join definitions, but that's no big deal. -- Posted via http://www.ruby-forum.com/. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.