instance method find_sole_by

Ruby on Rails 8.0.4

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

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

arg req
args rest
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

Type at least 2 characters to search.

↑↓ navigate · open · esc close