4

我有一个 Active Admin 模型:gallery,它有一个嵌套的回形针资源:images。:gallery has_many :图片。

:gallery 有一个字段 :title,它是必需的。

当我提交没有标题时,其他字段仍然存在(:描述,:位置),但嵌套资源变为空白。

有没有办法在验证之前构建资源,以便在验证检查失败后仍然存在?

f.inputs "Images" do 
      f.has_many :images do |i| 

          i.input :image,
                :as=>:file,
                :multipart => true, 
                :label => "Image" 
              end
    end
4

1 回答 1

1

请检查您是否在图库模型中添加了这些必需的东西

 attr_accessible :images_attributes

 accepts_nested_attributes_for :images, :allow_destroy => :true
于 2012-11-19T14:38:30.377 回答