Help with Associations: Templates, Documents and Options

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs