Douglas Shearer wrote:
Best way to explain this is with some code..
id_arr = [1,2,3,4,5] # There is no record with id 5. => results = find(id_arr) ActiveRecord::RecordNotFound: Couldn't find all Posts with IDs (1,2,3,4,5).
From reading the documentation it appears that AR will produce this error if ALL the ids do not return errors, but it appears to error when one or more of the ids does not return.
Any way to get those id's which do exist to return, without the error? From memory (I don't remember if you need something like id_arr.join(',') in the conditions instead of just id_arr):
results = id_arr.empty? ? : find(:all, :conditions => [ 'id IN (?)', id_arr ])