Search code examples
ruby-on-railsrubyactiverecord

Check if record was just destroyed in rails


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?


Solution

  • Just do it:

    record.destroyed?
    

    Details are here ActiveRecord::Persistence