如何确定Rails对象是否为marked_for_destruction?

时间:2009-10-12 16:37:46

标签: ruby-on-rails activerecord

我有一些碰巧是其他东西的嵌套属性的对象。 当它们被标记为要删除时,Rails会创建一个属性“marked_for_destruction”。 我该如何阅读这个var?

示例Yaml转储:

--- &id001 !ruby/object:LineItem 
attributes: 
  name:Pay
  created_at: 2009-10-12 16:30:51
  updated_at: 2009-10-12 16:30:51
  statement_id: "8"
  amount: "234"
  id: "33"
attributes_cache: {}

errors: !ruby/object:ActiveRecord::Errors 
  base: *id001
  errors: {}

marked_for_destruction: true

1 个答案:

答案 0 :(得分:11)

Object.marked_for_destruction?