Check if record was just destroyed in rails
You can do this.
Record.exists?(record.id)
However that will do a hit on the database which isn't always necessary. The only other solution I know is to do a callback as theIV mentioned.
attr_accessor :destroyedafter_destroy :mark_as_destroyeddef mark_as_destroyed self.destroyed = trueend
And then check record.destroyed
.
This is coming very soon. In the latest Riding Rails post, it says this:
And finally, it's not necessarily BugMash-related, but José Valim - among dozens of other commits - added model.destroyed?. This nifty method will return true only if the instance you're currently looking at has been successfully destroyed.
So there you go. Coming soon!