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

Nei*_*ton 4 activerecord ruby-on-rails

我有一些碰巧是其他东西的嵌套属性的对象.当它们被标记为要删除时,Rails会创建一个属性"marked_for_destruction".我怎么读这个变量?

示例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
Run Code Online (Sandbox Code Playgroud)

Nei*_*ton 12

Object.marked_for_destruction?
Run Code Online (Sandbox Code Playgroud)