instance method
find_with_ids
Ruby on Rails 3.1.12
Since v3.0.20Signature
find_with_ids(*ids)
No documentation comment.
Parameters
-
idsrest
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 298
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
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 298
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods