If you are using a FormBuilder, maybe you can prefer use this for generate the checkbox name. For example, if we have a form with nested forms for a has_many association and each of these need a category_ids collection of checkboxes calculate the name of these checkboxes can be a problem. So, I suggest use the object_name method of the FormBuilder object:
If you are using a
FormBuilder
, maybe you can prefer use this for generate the checkbox name. For example, if we have a form with nested forms for a has_many association and each of these need a category_ids collection of checkboxes calculate the name of these checkboxes can be a problem. So, I suggest use theobject_name
method of theFormBuilder
object:Note that I use
f.object
instead of@product
too. I think this way is better for use with aFormBuilder
.Finally, as you can see, I use an input hidden for be sure always send a category_ids array, so, I don't need setup this field in the controller.
I hope you find it useful :)