Hi all, I''m working on a project for a local charity to track donors, donations, assets, and a few other things. They would like the ability to attach files/documents to all of their records. Do I have to setup database tables and models for each of my models or is there some way to have a generic document class that can belong_to anything? In other words, rather than setting up donor_documents, donation_documents, and asset_documents, is there some way I can set up a single documents model??? Thanks for the input! -- 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-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 -~----------~----~----~----~------~----~------~--~---
> I''m working on a project for a local charity to track donors, donations, > assets, and a few other things. They would like the ability to attach > files/documents to all of their records. > > Do I have to setup database tables and models for each of my models or > is there some way to have a generic document class that can belong_to > anything? > > In other words, rather than setting up donor_documents, > donation_documents, and asset_documents, is there some way I can set up > a single documents model???You want a polymorphic model... and that does exactly what you''re talking about. look in the docs for has_many and the polymporphic section. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---