在我的JSONB列

时间:2016-05-06 20:14:47

标签: ruby-on-rails hstore jsonb

我的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。)

0 个答案:

没有答案