Nested Forms
Something I tend to forget often is, what is a nested form? What does that do for me? I’ve stepped away from Rails for a little time now working on the front end, so I needed a refresher! So to answer, what is a nested form? Its a form inside a form.
What’s shown above is an example of what a nested form is. We start at clothing, then we have two nested forms of men’s and women’s and it goes deeper; For men’s it goes to suits, go a step deeper it transitions to slacks and jackets. For women the same occurs but with dresses, skirts and blouses. These are nested forms and you’ll see these on any type of clothing website.
So now we’re gonna take a look at my project that was done with rails. We’re gonna look at the models folder, first is the sneaker.rb which holds a class of Sneaker and that it belongs to a User, it is optional but its still nested depending on what boolean it results are.
Now for the User model class, it has many reviews and sneakers through reviews. This is another example of a nested route. Not too much to talk about! But something that I found that was very important to me. Thank you so much for reading!