I just can't seem to figure this out. I can do this no problem using
each_with_index and iterating through an array set up in the
controller's "New." But that only allows me to finite number of
records. I'd like for the user to be able to dynamically pick the
number records just by clicking "Add Another."
Ryan Bates walks us through a similar problem in his Complex Forms
series, specifically episode 2. However, that example is for 2 models
in the one form (one model is nested). My form is just the 1 model
but many times. This seems so simple, but I can't figure it out. If
partial, the input fields end up getting labeled the same as the
fields I generated by iterating through my New array (i.e. all of the
the fields are model[model_attribute]). I don't know how to
So any ideas?
Also, is this even the best way to solve this problem? I know there's
a slightly different method in the Advanced Rails Recipes book, again
by Mr. Bates, but I can't seem to adapt that to use the "add another"
This seems like it'd be a common problem, 1 model many times
(dynamically) in 1 form, but haven't been able to find enough out
there to solve my problem. Any ideas? Am I even going about this the
right way? Or, is there a better way?
Any help is greatly appreciated.