2009-10-12 58 views
2

我有一些碰巧是其他東西的nested_attributes的對象。 當它們被標記爲刪除時,Rails創建一個屬性「marked_for_destruction」。 我該如何閱讀這個var?如何確定Rails對象是否被標記爲要破壞?

樣品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 

回答

8
Object.marked_for_destruction?