# Help with Associations: Templates, Documents and Options

**URL:** <https://www.ruby-forum.com/t/help-with-associations-templates-documents-and-options/182291>\
**Category:** Rails\
**Created:** [January 26, 2010, 7:25am UTC](https://www.ruby-forum.com/t/help-with-associations-templates-documents-and-options/182291 "2010-01-26T07:25:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anmueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/90ced4/32.png) [@anmueller](https://www.ruby-forum.com/u/anmueller)\
**Post date:** [January 26, 2010, 7:25am UTC](https://www.ruby-forum.com/t/help-with-associations-templates-documents-and-options/182291/1 "2010-01-26T07:25:27Z")

</div>

So I have a rails project that I’m working on and I have it doing what  
I want, but I’m fairly certain what I’ve done is at best a horrendous  
hack.

I was wondering if anyone could give me a very general suggestion for  
my associations.

Here’s the overview of my project:

The site will have document templates (I’ll actually call them  
patterns in the app because ‘template’ apparently is a reserved word  
in rails), which will have certain options. Other users can create  
documents based on the template using a form with questions based on  
the options from the template.

The way I’m doing I have implemented it right now is as follows:  
Each template has many documents. Each template has a field storing  
the options as a string. Each document belong to a template. Each  
document has many options. When a document is created, the options  
string from the template is parsed and the values are used to create  
new options for the document. Then I have a form that asks questions  
based on each of the options for the document. Like I said above, I’m  
certain this is a hilariously awful hack.

The more I think about it, the more I feel like that that templates  
should have many options and have many documents. That way I could set  
the options up when the template is created. But then I don’t know how  
to associate those options back to a document so that I can create a  
form that will fill out the template’s options to be used in the  
document.

I think I may be missing something not so obvious. I’m sure a lot of  
this is my inexperience with things like polymorphic associations, and/  
or self-referential associations and/or single table inheritance.

Anyway, I would appreciate some very top-down suggestions.

-Alexis M.
