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 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):
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?
There may be an easier way, but something like this will do it: