method
find_one
v4.2.7 -
Show latest stable
- Class:
ActiveRecord::FinderMethods
find_one(id)protected
No documentation available.
# File activerecord/lib/active_record/relation/finder_methods.rb, line 432
def find_one(id)
if ActiveRecord::Base === id
id = id.id
ActiveSupport::Deprecation.warn( You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`.squish)
end
relation = where(primary_key => id)
record = relation.take
raise_record_not_found_exception!(id, 0, 1) unless record
record
end