【问题标题】:check_box with fields_for带有 fields_for 的复选框
【发布时间】:2013-09-21 18:53:54
【问题描述】:

这是代码

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

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

发生的情况是,在未选中复选框的情况下更新模型时,is_visible 保持为真。此问题已记录在案,建议的修复方法是 In that case it is preferable to either use check_box_tag or to use hashes instead of arrays.

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

【问题讨论】:

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


    【解决方案1】:

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

    在控制器中允许visible 修复了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-19
      • 2010-11-16
      • 2018-02-19
      • 2011-08-04
      • 1970-01-01
      相关资源
      最近更新 更多