find_by(arg, *args)
public
Finds the first
record matching the specified conditions. There is no implied ordering so
if order matters, you should specify it yourself.
If no record is found, returns nil.
Post.find_by name: 'Spartacus', rating: 4
Post.find_by "published_at < ?", 2.weeks.ago
# File activerecord/lib/active_record/relation/finder_methods.rb, line 103
def find_by(arg, *args)
where(arg, *args).take
end