How to submit multiple NEW items via Rails 3.2 mass-assignment

前端 未结 8 1493
醉梦人生
醉梦人生 2020-12-04 06:33

I have a pretty standard use-case. I have a parent object and a list of child objects. I want to have a tabular form where I can edit all the children at once, as rows in th

8条回答
  •  粉色の甜心
    2020-12-04 07:13

    Maybe you should just cheat. Put the new records in a different faux attribute that is a decorator for the actual one.

    parent[children_attributes][0][fieldname]
    parent[new_children_attributes][][fieldname]
    

    It's not pretty, but it should work. It might take some extra effort to support round-trips to the form for validation errors.

提交回复
热议问题