I'm building a form with nested attributes (accepts_nested_attributes_for). One of the nested models uses paperclip. I'm developing the following solution for deleting attachments: https://*.com/a/8062259/503141
我正在构建一个具有嵌套属性的表单(accepts_nested_attributes_for)。其中一个嵌套模型使用回形针。我正在开发以下删除附件的解决方案:https://*.com/a/8062259/503141
The problem I face is that, when the main object is saved, the nested model is only saved if the submodel has changed and the avobe solution does not work.
我面临的问题是,当保存主对象时,只有在子模型发生变化且avobe解决方案不起作用时才会保存嵌套模型。
Is there any how to change this behaviour?
有没有怎么改变这种行为?
Thanks
谢谢
1 个解决方案
#1
0
Nested models are saved according to changed? method. Therefore you need to overwrite changed? method accordingly. In this case would be:
嵌套模型是根据更改保存的?方法。因此你需要覆盖改变?方法因此。在这种情况下将是:
def changed?
(photo_delete == '1') || super
end
#1
0
Nested models are saved according to changed? method. Therefore you need to overwrite changed? method accordingly. In this case would be:
嵌套模型是根据更改保存的?方法。因此你需要覆盖改变?方法因此。在这种情况下将是:
def changed?
(photo_delete == '1') || super
end