instance method
find_by
Ruby on Rails edge
Since v4.0.13Signature
find_by(arg, *args)
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 “‘
Parameters
-
argreq -
argsrest
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 127
def find_by(arg, *args)
where(arg, *args).take
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 127
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods