There are ten ways to do anything but what is the best practice approach to organizing the Document and Section models described below in Rails?
Documents can have n number of sections. Each Section can be a specialized type of section with its own attributes and associations differing from other sections. And each Document needs to track a section order state for all of the sections associated with it regardless of type.
I could create model classes for each Section type and associate them on Document as has_many SectionTypeA, has_many SectionTypeA and write a sorting mechanism to put together a sorted collection of all types for the given document.
I looked into Single Table Inheritance. But the STI approach seems questionable when the specialized attributes are more complicated than a few string or integer fields. Sections will have attributes that map to database text columns and their own section has_many, has_one associations.
Here's a rough outline of the elements described:
Document
Sections
-Section Type A
Title, freeform text
-Section Type B
Title, collection of urls
-Section Type C
Title, collection of images with title and collection of image comments
Titleattribute, you might want to just create separate associations for each type.