我的JSONB列中有一个数组键,我想在其中存储哈希值。
class Product < ActiveRecord::Base
store_accessor :data, :foos
# foo = []
end
class ProductForm
#
end
form_for @product_form do |f|
# stuff
f.fields_for :foos do |ff|
<fieldset class="foos">
ff.input :bat # options
ff.input :buzz
</fieldset>
end
link_to_add_fields # args
end
但我想让fields_for
动态接受多个foos,但在我手工写出原始html之前,我想知道是否有更惯用的方法。
(我怀疑在hstore
中使用的解决方案也适用于jsonb
。)