标签: ruby-on-rails activerecord destroy
在我的rails应用程序中,子记录得到marked_for_destruction我想撤消该操作并取消标记。有办法吗?
提前致谢。
答案 0 :(得分:10)
child.reload if child.marked_for_destruction?
来自ActiveRecord::AutosaveAssociation:
<强> reload 强> (options = nil) 照常重新加载对象的属性并清除marked_for_destruction标志。
<强> reload 强> (options = nil)
reload
(options = nil)
照常重新加载对象的属性并清除marked_for_destruction标志。