Check if record was just destroyed in rails

Daniel Huckstep picture Daniel Huckstep · Aug 19, 2009 · Viewed 37.3k times · Source

So there is

record.new_record?

To check if something is new

I need to check if something is on it's way out.

record = some_magic
record.destroy
record.is_destroyed? # => true

Something like that. I know destroying freezes the object, so frozen? sort of works, but is there something explicitly for this task?

Answer

Voldy picture Voldy · Aug 11, 2010

Just do it:

record.destroyed?

Details are here ActiveRecord::Persistence