form_for non-AR model - fields_for Array attribute doesn't iterate

后端 未结 3 422
野趣味
野趣味 2020-12-30 09:15

I\'m having trouble getting fields_for to work on an Array attribute of a non-ActiveRecord model.

Distilled down, I have to following:

models/pa

3条回答
  •  暖寄归人
    2020-12-30 10:04

    I ditched the fields_for and added multiple: true

    = form_for @parent, :url => new_parent_path do |f|
      - @parent.bars.each_with_index do |bar, i|
        = f.text_field :bars, value: bar, multiple: true, id: "bar#{i}"
    

提交回复
热议问题