Skip to content

Headache with "has_many through" associations #616

Description

@MissHenesy

Hey, Nathan!

I'm attempting to use Cocoon's dynamic goodness with a very simple demo project that consists of 3 models.
The only problem I'm running into is that my tables have a "Document | Sections | Paragraphs" structure.

Because Documents have many Sections, and Sections have many Paragraphs, I'm only able to render Documents --> Sections with "link_to_add_association"; when I try to render Documents --> Paragraphs, I receive an error::

"Cannot modify association 'Document#section_paragraphs' because the source reflection class 'Paragraphs' is associated to 'Section' via :has_many.

I can't really change my associations, because it is just true that 1 Document will have many Sections, and 1 Section will have many Paragraphs. Sections don't belong to Paragraphs, but since it's being used as a "through", Rails is getting (and giving) a headache.

Is there a way around this? I'm tempted to just put a *#@ document_id in the Paragraphs table, but I'd like to avoid that, if possible.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions