method

find_first

rails latest stable - Class: ActiveRecord::FinderMethods

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v4.0.2) is shown here.

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