find_by_scan(*args)
private
If using a custom finder_sql or if the :inverse_of option has been
specified, then #find
scans the entire collection.
# File activerecord/lib/active_record/associations/collection_association.rb, line 584
def find_by_scan(*args)
expects_array = args.first.kind_of?(Array)
ids = args.flatten.compact.map{ |arg| arg.to_s }.uniq
if ids.size == 1
id = ids.first
record = load_target.detect { |r| id == r.id.to_s }
expects_array ? [ record ] : record
else
load_target.select { |r| ids.include?(r.id.to_s) }
end
end