method
find_one
v3.0.0 -
Show latest stable
- Class:
ActiveRecord::FinderMethods
find_one(id)protected
No documentation available.
# File activerecord/lib/active_record/relation/finder_methods.rb, line 288
def find_one(id)
id = id.id if ActiveRecord::Base === id
record = where(primary_key.eq(id)).first
unless record
conditions = arel.wheres.map { |x| x.value }.join(', ')
conditions = " [WHERE #{conditions}]" if conditions.present?
raise RecordNotFound, "Couldn't find #{@klass.name} with ID=#{id}#{conditions}"
end
record
end