What is the most efficient way to find the first matching record?

ruby, ruby-on-rails

Solution

`User.find_by(first_name: 'Fred') # it finds the first user` http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find_by

Problem

For instance, user = find the first Fred from a list of users

Original source