Using fields_for to edit multiple records without a parent record
In learning Rails, I was also introduced to Rails’ myriad of helper methods. I was especially drawn to Rails’ HTML Form helper methods, form_tag, form_for, and form_with. They are extremely powerful helpers that turn writing HTML into a breeze. In addition to those form helper basics, we also learned about nested forms, and were able to create forms that could edit or create multiple records with a simple helper — fields_for:
However, this came with a bit of a caveat. The default use of fields_for is to use for an object with a parent/belongs_to object. This way, we can use Rails’ “accept_nested_attributes_for” macro in order to easily mass assign attributes to new objects. All the primary documentation on APIDock point used this method and showed instances of one-to-many, many-to-many, and one-to-one relationships.
Looking further into it, I found some examples of people using fields_for in a way to mass assign attributes to multiple records without a nested association. In fact, you can also use fields_for outside of the confines of a form_for, which most documentation examples exhibited. See below for the code:
The above ERB file will look like this in the browser:

As you can see from the code snippet, you can iterate over an array of topics using the each enumerable, and then set fields for each of them. In my example above, I wanted to change to be able to change the enabled boolean at will for my list of topics.
“topics[]” will be the parameter for these fields, using empty square brackets that will turn these fields into a nested hash in the params, with the keys being the ids of the objects being edited.

After receiving these params, you can then post it to your controller action of choice and mass create/update your records.