Skip to main content

Nested Model of an already nested model

Rails • Asked by RJ McCollam

I want to make sure my thinking is right more than anything else on this post. Hopefully I can explain myself clearly and get pointed in a good direction.

My Scenario

I have 3 models. Model A, Model B, and Model C.

Model A is the top level model and has Model B nested underneath it through a belongs_to/has_many setup.

I am needing to add a nested model (Model C) to Model B. Model C has not dependcy on Model A. Only Model B.

In building out Model C can I just go about it as I normally would using a belongs_to/has_many setup?

I imagine that going another level deep with nesting is possible, but I also imagine there are some special things to look out for in my routing and form setup.

My question in all of this being can I do it and what should I watch out for in doing so?


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.