instance method
find_first
Ruby on Rails 4.0.13
Since v3.0.20 Last seen in v4.0.13Signature
find_first()
No documentation comment.
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 320
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
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 320
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods