Try ActiveRecord's exists? method. Haven't used it, but looks good. - Adam
On Feb 6, 2008 11:34 AM, Glenn Little <[EMAIL PROTECTED]> wrote: > > What is the "best practice" for determining whether or not > a model object corresponds to a database record that has been > deleted? > > Say I have a collection of Book objects, some of which have > been removed from the database with: > > @book = Book.find(blah) > @book.destroy > ... > @books << @book # don't know at this point whether @book has been > destroyed > > Now when I iterate through @books, I'd like to detect the > ones that have been destroyed. > > It appears that the destroyed ones will be "frozen" (@book.frozen? == > true), > but assuming that frozen == destroyed seems somehow indirect > and side-effecty. Is there a more straighforward way (short of > re-querying > the database) that I'm missing? > > Thanks... > > -glenn > > > > --~--~---------~--~----~------------~-------~--~----~ SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby -~----------~----~----~----~------~----~------~--~---
