Method: ActiveRecord::FinderMethods#first

Defined in:
lib/active_record/relation/finder_methods.rb

#first(*args) ⇒ Object

A convenience wrapper for find(:first, *args). You can pass in all the same arguments to this method as you can to find(:first).



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/active_record/relation/finder_methods.rb', line 114

def first(*args)
  if args.any?
    if args.first.kind_of?(Integer) || (loaded? && !args.first.kind_of?(Hash))
      limit(*args).to_a
    else
      apply_finder_options(args.first).first
    end
  else
    find_first
  end
end