instance method
find_one
Ruby on Rails 6.1.7.10
Since v3.0.20 PrivateSignature
find_one(id)
No documentation comment.
Parameters
-
idreq
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 465
def find_one(id)
if ActiveRecord::Base === id
raise ArgumentError, <<-MSG.squish
You are passing an instance of ActiveRecord::Base to `find`.
Please pass the id of the object by calling `.id`.
MSG
end
relation = where(primary_key => id)
record = relation.take
raise_record_not_found_exception!(id, 0, 1) unless record
record
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 465
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods