method
find_some

Register or
log in
to add new notes.
bansalakhil -
February 13, 2009
reynardmh -
November 3, 2010
metavida -
November 3, 2010

1 thank
throws exception
when use use Model.find([1,2,3,4])
throws exception if no record exists with any of this ID

1 thank
correction
I think what metavida meant was
User.find(1, 3) # ActiveRecord::RecordNotFound error
not
User.find_by_id(1, 3) # this will just return user 1

0 thanks
RecordNotFound when any id not found
As an example of bansalakhil’s explanation.
User.find_by_id(1) #=> #<User:0x3d54a3c @attributes={"id"=>1}> User.find_by_id(2) #=> #<User:0x3d519a4 @attributes={"id"=>2}> User.find_by_id(3) #=> nil User.find_by_id(1, 2) #=> an Array with 2 User instances User.find_by_id(1, 3) #=> an ActiveRecord::RecordNotFound error