Ruby on Rails - 撤消mark_for_destruction

时间:2011-02-22 15:58:35

标签: ruby-on-rails activerecord destroy

在我的rails应用程序中,子记录得到marked_for_destruction我想撤消该操作并取消标记。有办法吗?

提前致谢。

1 个答案:

答案 0 :(得分:10)

child.reload if child.marked_for_destruction?

来自ActiveRecord::AutosaveAssociation

  

<强> reload (options = nil)

     

照常重新加载对象的属性并清除marked_for_destruction标志。