method
find_with_ids
v3.2.8 -
Show latest stable
- Class:
ActiveRecord::FinderMethods
find_with_ids(*ids)protected
No documentation available.
# File activerecord/lib/active_record/relation/finder_methods.rb, line 300
def find_with_ids(*ids)
return to_a.find { |*block_args| yield(*block_args) } if block_given?
expects_array = ids.first.kind_of?(Array)
return ids.first if expects_array && ids.first.empty?
ids = ids.flatten.compact.uniq
case ids.size
when 0
raise RecordNotFound, "Couldn't find #{@klass.name} without an ID"
when 1
result = find_one(ids.first)
expects_array ? [ result ] : result
else
find_some(ids)
end
end