method
find_first
v4.0.2 -
Show latest stable
- Class:
ActiveRecord::FinderMethods
find_first()protected
No documentation available.
# File activerecord/lib/active_record/relation/finder_methods.rb, line 319
def find_first
if loaded?
@records.first
else
@first ||=
if with_default_scope.order_values.empty? && primary_key
order(arel_table[primary_key].asc).limit(1).to_a.first
else
limit(1).to_a.first
end
end
end