Steven Brooks' Blog

Student @Flatiron School

Day 7...Took Four Models Into One Model

After over a week of tinkering with my form for my workout app, spending hours with TA’s, and even looking to the Stack Overflow community, I have finally figured out my form. I now know how to create a form where four models are being used, create all of their associations in the controller, and display them properly in the view. That’s Rails ladies and gentlemen.

Here is my form (which will be changed with some jquery soon):

My params

The trick here was that I wanted many instances of “lifts” in an array, so creating the variable “n” and interpolating that variable into the form fields basically set “n” as a counter.

Then this is how I tied everything together in the controller (which will probably be cleaned up as some point):

My params

Not bad at all.