我有一个Active Admin模型,:gallery,它有一个嵌套的回形针资源:images。 :gallery has_many:images。
:gallery有一个字段,:title,这是必需的。
当我提交而没有标题时,其他字段仍然存在(:description,:location),但嵌套资源变为空白。
有没有办法在验证之前构建资源,因此在验证失败后它会持续存在?
f.inputs "Images" do
f.has_many :images do |i|
i.input :image,
:as=>:file,
:multipart => true,
:label => "Image"
end
end
答案 0 :(得分:1)
请检查您是否在图库模型
中添加了这些必需的内容 attr_accessible :images_attributes
和
accepts_nested_attributes_for :images, :allow_destroy => :true