Form input arrays

With strong parameters, define the array instants as :instant_name = [] in the controller.

Then the data needs to serialized before the model saves the data–so in the model define serialize :instant_name. However, ignoring empty arrays might be a good thing–so also include

before_save { self.instant_name.reject! { |a| a.empty? } }

to make sure empty items aren’t saved.

To create the array of inputs, in this case use the text_field_tag,


Providing additional attributes is optional.