# Best Practice: Document Attachments

**URL:** <https://www.ruby-forum.com/t/best-practice-document-attachments/115706>\
**Category:** Rails\
**Created:** [September 27, 2007, 8:17pm UTC](https://www.ruby-forum.com/t/best-practice-document-attachments/115706 "2007-09-27T20:17:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gfook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/46a35a/32.png) [@gfook](https://www.ruby-forum.com/u/gfook)\
**Post date:** [September 27, 2007, 8:17pm UTC](https://www.ruby-forum.com/t/best-practice-document-attachments/115706/1 "2007-09-27T20:17:39Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gfook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/46a35a/32.png) [@gfook](https://www.ruby-forum.com/u/gfook)\
**Post date:** [September 28, 2007, 1:00am UTC](https://www.ruby-forum.com/t/best-practice-document-attachments/115706/2 "2007-09-28T01:00:30Z")

</div>

> 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.
