How to avoid ActiveRecord::RecordNotFound exceptions when querying multiple records

Viewed 7057

I have this code:

Article.find([1,2,3])

But only record 1 and 2 exist in the database. I get this exception:

"ActiveRecord::RecordNotFound (Couldn't find all Offers with IDs (1,2,3) (found 2 results, but was looking for 3))"

Is there a way to only get the existing records and not the exception?

3 Answers
Related