自定义 form_for collection_check_boxes 查看结果

Customize form_for collection_check_boxes view result

根据应用样式,带有form_for的复选框如下:

%label
  Show featured data?
  = f.check_box :on_display
  %i

现在在 has_and_belongs_to_many 关系中,我需要使用 collection_check_boxes form_for 助手,并且需要编辑以相同的方式显示每个结果。

已解决!

Here a reference for solve

collection_check_boxes 不是这样,并完成了 以下代码:

- Team.all.each do |t|
            %label
              ="Available on #{t.name}"
              = check_box_tag '[team_ids][]', t.id
              %i