rails ActiveAdmin nested form has_one accepts_attributes_for formtastic issue

后端 未结 3 1142
清歌不尽
清歌不尽 2020-12-13 14:44

I am using ActiveAdmin and Rails 3.1 -- having problem understanding whether the following is a bug, or if there is some way to do it correctly that I am not understanding.

3条回答
  •  执笔经年
    2020-12-13 15:12

    I found a better solution for you. You can use :for option in inputs helper.

    f.inputs "Meta Data", for: [:meta_data, f.object.meta_data || MetaData.new] do |meta_form|
      meta_form.input :title
      meta_form.input :description
      meta_form.input :keywords
    end
    

    I think this might work too, but I didn't check

    f.inputs :title, :desctiption, :keywords, 
      name: "Meta Data",
      for: [:meta_data, f.object.meta_data || MetaData.new]
    

提交回复
热议问题