Get an array from a Rails form

后端 未结 5 1261
野趣味
野趣味 2021-01-12 13:10

I need to design a form for a account resource. In that form, i need to collect some set of ids as an array in the params hash in attribute called

5条回答
  •  梦谈多话
    2021-01-12 14:01

    In a complex form, with nested attributes, you can make use of the f.object_name helper. But beware of the syntax when doing interpolation. This is correct:

    "#{f.object_name}[relationships][]"
    

    This is NOT correct:

    "#{f.object_name}[relationships[]]"
    

    It always trips me up.

提交回复
热议问题