check_box with fields_for

时间:2013-09-21 18:53:55

标签: ruby-on-rails checkbox nested-attributes fields-for

这是代码

= f.fields_for :category do |fc|
  = fc.check_box :is_visible

我遇到了这里描述的情况http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-check_box Unfortunately that workaround does not work when the check box goes within an array-like parameter, as in ...

当未选中复选框更新模型时,is_visible保持为true。记录此问题,建议的修复程序为In that case it is preferable to either use check_box_tag or to use hashes instead of arrays.

我不知道如何实施解决方案。请指教。

1 个答案:

答案 0 :(得分:0)

它确实有效,问题是Unpermitted parameters: visible

允许控制器中的visible修复此问题。