instance method
find_sole_by
Ruby on Rails 8.1.2
Since v7.0.10Signature
find_sole_by(arg, *args)
Finds the sole matching record. Raises ActiveRecord::RecordNotFound if no record is found. Raises ActiveRecord::SoleRecordExceeded if more than one record is found.
Product.find_sole_by(["price = %?", price])
Parameters
-
argreq -
argsrest
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 160
def find_sole_by(arg, *args)
where(arg, *args).sole
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 160
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods