method
find_one
rails latest stable - Class:
ActiveRecord::FinderMethods
find_one(id)private
No documentation available.
# File activerecord/lib/active_record/relation/finder_methods.rb, line 506
def find_one(id)
if ActiveRecord::Base === id
raise ArgumentError, You are passing an instance of ActiveRecord::Base to `find`. Please pass the id of the object by calling `.id`..squish
end
relation = if klass.composite_primary_key?
where(primary_key.zip(id).to_h)
else
where(primary_key => id)
end
record = relation.take
raise_record_not_found_exception!(id, 0, 1) unless record
record
end